diff --git a/copyright.txt b/copyright.txt index c9e117b57..02bded5b0 100644 --- a/copyright.txt +++ b/copyright.txt @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # diff --git a/openlp.py b/openlp.py index 1c51338fc..e3023e536 100755 --- a/openlp.py +++ b/openlp.py @@ -5,7 +5,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # diff --git a/openlp/.version b/openlp/.version index 8bbe6cf74..2bf1c1ccf 100644 --- a/openlp/.version +++ b/openlp/.version @@ -1 +1 @@ -2.2 +2.3.1 diff --git a/openlp/__init__.py b/openlp/__init__.py index 1ccc9dc76..a78a2bebb 100644 --- a/openlp/__init__.py +++ b/openlp/__init__.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # diff --git a/openlp/core/__init__.py b/openlp/core/__init__.py index 642ad77c5..196317b06 100644 --- a/openlp/core/__init__.py +++ b/openlp/core/__init__.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # diff --git a/openlp/core/common/__init__.py b/openlp/core/common/__init__.py index ab3b79657..b0926dccd 100644 --- a/openlp/core/common/__init__.py +++ b/openlp/core/common/__init__.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # diff --git a/openlp/core/common/applocation.py b/openlp/core/common/applocation.py index 06736c3b0..35fcd73d8 100644 --- a/openlp/core/common/applocation.py +++ b/openlp/core/common/applocation.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # diff --git a/openlp/core/common/historycombobox.py b/openlp/core/common/historycombobox.py index 2e15dc6f4..f0ec7c2ad 100644 --- a/openlp/core/common/historycombobox.py +++ b/openlp/core/common/historycombobox.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # diff --git a/openlp/core/common/openlpmixin.py b/openlp/core/common/openlpmixin.py index 4023f6506..d17f36bd6 100644 --- a/openlp/core/common/openlpmixin.py +++ b/openlp/core/common/openlpmixin.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # diff --git a/openlp/core/common/registry.py b/openlp/core/common/registry.py index 048654353..adf495a36 100644 --- a/openlp/core/common/registry.py +++ b/openlp/core/common/registry.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # diff --git a/openlp/core/common/registrymixin.py b/openlp/core/common/registrymixin.py index 7feaaeaa7..b46aa93a7 100644 --- a/openlp/core/common/registrymixin.py +++ b/openlp/core/common/registrymixin.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # diff --git a/openlp/core/common/registryproperties.py b/openlp/core/common/registryproperties.py index 88c12c834..ce138d5f6 100644 --- a/openlp/core/common/registryproperties.py +++ b/openlp/core/common/registryproperties.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # diff --git a/openlp/core/common/settings.py b/openlp/core/common/settings.py index be78c7b79..0bedd69b6 100644 --- a/openlp/core/common/settings.py +++ b/openlp/core/common/settings.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # @@ -26,7 +26,7 @@ import datetime import logging import os -from PyQt5 import QtCore, QtGui +from PyQt5 import QtCore, QtGui, QtWidgets from openlp.core.common import ThemeLevel, SlideLimits, UiStrings, is_win, is_linux @@ -170,142 +170,6 @@ class Settings(QtCore.QSettings): 'SettingsImport/Make_Changes': 'At_Own_RISK', 'SettingsImport/type': 'OpenLP_settings_export', 'SettingsImport/version': '', - 'shortcuts/aboutItem': [QtGui.QKeySequence('Ctrl+F1')], - 'shortcuts/addToService': [], - 'shortcuts/audioPauseItem': [], - 'shortcuts/displayTagItem': [], - 'shortcuts/blankScreen': [QtGui.QKeySequence(QtCore.Qt.Key_Period)], - 'shortcuts/collapse': [QtGui.QKeySequence(QtCore.Qt.Key_Minus)], - 'shortcuts/desktopScreen': [QtGui.QKeySequence('D')], - 'shortcuts/delete': [], - 'shortcuts/down': [QtGui.QKeySequence(QtCore.Qt.Key_Down)], - 'shortcuts/editSong': [], - 'shortcuts/escapeItem': [QtGui.QKeySequence(QtCore.Qt.Key_Escape)], - 'shortcuts/expand': [QtGui.QKeySequence(QtCore.Qt.Key_Plus)], - 'shortcuts/exportThemeItem': [], - 'shortcuts/fileNewItem': [QtGui.QKeySequence('Ctrl+N')], - 'shortcuts/fileSaveAsItem': [QtGui.QKeySequence('Ctrl+Shift+S')], - 'shortcuts/fileExitItem': [QtGui.QKeySequence('Alt+F4')], - 'shortcuts/fileSaveItem': [QtGui.QKeySequence('Ctrl+S')], - 'shortcuts/fileOpenItem': [QtGui.QKeySequence('Ctrl+O')], - 'shortcuts/goLive': [], - 'shortcuts/importThemeItem': [], - 'shortcuts/importBibleItem': [], - 'shortcuts/listViewBiblesDeleteItem': [QtGui.QKeySequence(QtCore.Qt.Key_Delete)], - 'shortcuts/listViewBiblesPreviewItem': [QtGui.QKeySequence(QtCore.Qt.Key_Enter), - QtGui.QKeySequence(QtCore.Qt.Key_Return)], - 'shortcuts/listViewBiblesLiveItem': [QtGui.QKeySequence(QtCore.Qt.ShiftModifier | QtCore.Qt.Key_Enter), - QtGui.QKeySequence(QtCore.Qt.ShiftModifier | QtCore.Qt.Key_Return)], - 'shortcuts/listViewBiblesServiceItem': [QtGui.QKeySequence(QtCore.Qt.Key_Plus), - QtGui.QKeySequence(QtCore.Qt.Key_Equal)], - 'shortcuts/listViewCustomDeleteItem': [QtGui.QKeySequence(QtCore.Qt.Key_Delete)], - 'shortcuts/listViewCustomPreviewItem': [QtGui.QKeySequence(QtCore.Qt.Key_Enter), - QtGui.QKeySequence(QtCore.Qt.Key_Return)], - 'shortcuts/listViewCustomLiveItem': [QtGui.QKeySequence(QtCore.Qt.ShiftModifier | QtCore.Qt.Key_Enter), - QtGui.QKeySequence(QtCore.Qt.ShiftModifier | QtCore.Qt.Key_Return)], - 'shortcuts/listViewCustomServiceItem': [QtGui.QKeySequence(QtCore.Qt.Key_Plus), - QtGui.QKeySequence(QtCore.Qt.Key_Equal)], - 'shortcuts/listViewImagesDeleteItem': [QtGui.QKeySequence(QtCore.Qt.Key_Delete)], - 'shortcuts/listViewImagesPreviewItem': [QtGui.QKeySequence(QtCore.Qt.Key_Enter), - QtGui.QKeySequence(QtCore.Qt.Key_Return)], - 'shortcuts/listViewImagesLiveItem': [QtGui.QKeySequence(QtCore.Qt.ShiftModifier | QtCore.Qt.Key_Enter), - QtGui.QKeySequence(QtCore.Qt.ShiftModifier | QtCore.Qt.Key_Return)], - 'shortcuts/listViewImagesServiceItem': [QtGui.QKeySequence(QtCore.Qt.Key_Plus), - QtGui.QKeySequence(QtCore.Qt.Key_Equal)], - 'shortcuts/listViewMediaDeleteItem': [QtGui.QKeySequence(QtCore.Qt.Key_Delete)], - 'shortcuts/listViewMediaPreviewItem': [QtGui.QKeySequence(QtCore.Qt.Key_Enter), - QtGui.QKeySequence(QtCore.Qt.Key_Return)], - 'shortcuts/listViewMediaLiveItem': [QtGui.QKeySequence(QtCore.Qt.ShiftModifier | QtCore.Qt.Key_Enter), - QtGui.QKeySequence(QtCore.Qt.ShiftModifier | QtCore.Qt.Key_Return)], - 'shortcuts/listViewMediaServiceItem': [QtGui.QKeySequence(QtCore.Qt.Key_Plus), - QtGui.QKeySequence(QtCore.Qt.Key_Equal)], - 'shortcuts/listViewPresentationsDeleteItem': [QtGui.QKeySequence(QtCore.Qt.Key_Delete)], - 'shortcuts/listViewPresentationsPreviewItem': [QtGui.QKeySequence(QtCore.Qt.Key_Enter), - QtGui.QKeySequence(QtCore.Qt.Key_Return)], - 'shortcuts/listViewPresentationsLiveItem': [QtGui.QKeySequence(QtCore.Qt.ShiftModifier | QtCore.Qt.Key_Enter), - QtGui.QKeySequence(QtCore.Qt.ShiftModifier | QtCore.Qt.Key_Return)], - 'shortcuts/listViewPresentationsServiceItem': [QtGui.QKeySequence(QtCore.Qt.Key_Plus), - QtGui.QKeySequence(QtCore.Qt.Key_Equal)], - 'shortcuts/listViewSongsDeleteItem': [QtGui.QKeySequence(QtCore.Qt.Key_Delete)], - 'shortcuts/listViewSongsPreviewItem': [QtGui.QKeySequence(QtCore.Qt.Key_Enter), - QtGui.QKeySequence(QtCore.Qt.Key_Return)], - 'shortcuts/listViewSongsLiveItem': [QtGui.QKeySequence(QtCore.Qt.ShiftModifier | QtCore.Qt.Key_Enter), - QtGui.QKeySequence(QtCore.Qt.ShiftModifier | QtCore.Qt.Key_Return)], - 'shortcuts/listViewSongsServiceItem': [QtGui.QKeySequence(QtCore.Qt.Key_Plus), - QtGui.QKeySequence(QtCore.Qt.Key_Equal)], - 'shortcuts/lockPanel': [], - 'shortcuts/modeDefaultItem': [], - 'shortcuts/modeLiveItem': [], - 'shortcuts/make_live': [QtGui.QKeySequence(QtCore.Qt.Key_Enter), QtGui.QKeySequence(QtCore.Qt.Key_Return)], - 'shortcuts/moveUp': [QtGui.QKeySequence(QtCore.Qt.Key_PageUp)], - 'shortcuts/moveTop': [QtGui.QKeySequence(QtCore.Qt.Key_Home)], - 'shortcuts/modeSetupItem': [], - 'shortcuts/moveBottom': [QtGui.QKeySequence(QtCore.Qt.Key_End)], - 'shortcuts/moveDown': [QtGui.QKeySequence(QtCore.Qt.Key_PageDown)], - 'shortcuts/nextTrackItem': [], - 'shortcuts/nextItem_live': [QtGui.QKeySequence(QtCore.Qt.Key_Down), QtGui.QKeySequence(QtCore.Qt.Key_PageDown)], - 'shortcuts/nextItem_preview': [QtGui.QKeySequence(QtCore.Qt.Key_Down), - QtGui.QKeySequence(QtCore.Qt.Key_PageDown)], - 'shortcuts/nextService': [QtGui.QKeySequence(QtCore.Qt.Key_Right)], - 'shortcuts/newService': [], - 'shortcuts/offlineHelpItem': [], - 'shortcuts/onlineHelpItem': [QtGui.QKeySequence('Alt+F1')], - 'shortcuts/openService': [], - 'shortcuts/saveService': [], - 'shortcuts/previousItem_live': [QtGui.QKeySequence(QtCore.Qt.Key_Up), QtGui.QKeySequence(QtCore.Qt.Key_PageUp)], - 'shortcuts/playbackPause': [], - 'shortcuts/playbackPlay': [], - 'shortcuts/playbackStop': [], - 'shortcuts/playSlidesLoop': [], - 'shortcuts/playSlidesOnce': [], - 'shortcuts/previousService': [QtGui.QKeySequence(QtCore.Qt.Key_Left)], - 'shortcuts/previousItem_preview': [QtGui.QKeySequence(QtCore.Qt.Key_Up), - QtGui.QKeySequence(QtCore.Qt.Key_PageUp)], - 'shortcuts/printServiceItem': [QtGui.QKeySequence('Ctrl+P')], - 'shortcuts/songExportItem': [], - 'shortcuts/songUsageStatus': [QtGui.QKeySequence(QtCore.Qt.Key_F4)], - 'shortcuts/searchShortcut': [QtGui.QKeySequence('Ctrl+F')], - 'shortcuts/settingsShortcutsItem': [], - 'shortcuts/settingsImportItem': [], - 'shortcuts/settingsPluginListItem': [QtGui.QKeySequence('Alt+F7')], - 'shortcuts/songUsageDelete': [], - 'shortcuts/settingsConfigureItem': [], - 'shortcuts/shortcutAction_B': [QtGui.QKeySequence('B')], - 'shortcuts/shortcutAction_C': [QtGui.QKeySequence('C')], - 'shortcuts/shortcutAction_E': [QtGui.QKeySequence('E')], - 'shortcuts/shortcutAction_I': [QtGui.QKeySequence('I')], - 'shortcuts/shortcutAction_O': [QtGui.QKeySequence('O')], - 'shortcuts/shortcutAction_P': [QtGui.QKeySequence('P')], - 'shortcuts/shortcutAction_V': [QtGui.QKeySequence('V')], - 'shortcuts/shortcutAction_0': [QtGui.QKeySequence('0')], - 'shortcuts/shortcutAction_1': [QtGui.QKeySequence('1')], - 'shortcuts/shortcutAction_2': [QtGui.QKeySequence('2')], - 'shortcuts/shortcutAction_3': [QtGui.QKeySequence('3')], - 'shortcuts/shortcutAction_4': [QtGui.QKeySequence('4')], - 'shortcuts/shortcutAction_5': [QtGui.QKeySequence('5')], - 'shortcuts/shortcutAction_6': [QtGui.QKeySequence('6')], - 'shortcuts/shortcutAction_7': [QtGui.QKeySequence('7')], - 'shortcuts/shortcutAction_8': [QtGui.QKeySequence('8')], - 'shortcuts/shortcutAction_9': [QtGui.QKeySequence('9')], - 'shortcuts/settingsExportItem': [], - 'shortcuts/songUsageReport': [], - 'shortcuts/songImportItem': [], - 'shortcuts/themeScreen': [QtGui.QKeySequence('T')], - 'shortcuts/toolsReindexItem': [], - 'shortcuts/toolsFindDuplicates': [], - 'shortcuts/toolsAlertItem': [QtGui.QKeySequence('F7')], - 'shortcuts/toolsFirstTimeWizard': [], - 'shortcuts/toolsOpenDataFolder': [], - 'shortcuts/toolsAddToolItem': [], - 'shortcuts/updateThemeImages': [], - 'shortcuts/up': [QtGui.QKeySequence(QtCore.Qt.Key_Up)], - 'shortcuts/viewProjectorManagerItem': [QtGui.QKeySequence('F6')], - 'shortcuts/viewThemeManagerItem': [QtGui.QKeySequence('F10')], - 'shortcuts/viewMediaManagerItem': [QtGui.QKeySequence('F8')], - 'shortcuts/viewPreviewPanel': [QtGui.QKeySequence('F11')], - 'shortcuts/viewLivePanel': [QtGui.QKeySequence('F12')], - 'shortcuts/viewServiceManagerItem': [QtGui.QKeySequence('F9')], - 'shortcuts/webSiteItem': [], 'themes/global theme': '', 'themes/last directory': '', 'themes/last directory export': '', @@ -379,6 +243,159 @@ class Settings(QtCore.QSettings): QtCore.QSettings.__init__(self, Settings.__file_path__, Settings.IniFormat) else: QtCore.QSettings.__init__(self, *args) + # Add shortcuts here so QKeySequence has a QApplication instance to use. + Settings.__default_settings__.update({ + 'shortcuts/aboutItem': [QtGui.QKeySequence(QtCore.Qt.CTRL + QtCore.Qt.Key_F1)], + 'shortcuts/addToService': [], + 'shortcuts/audioPauseItem': [], + 'shortcuts/displayTagItem': [], + 'shortcuts/blankScreen': [QtGui.QKeySequence(QtCore.Qt.Key_Period)], + 'shortcuts/collapse': [QtGui.QKeySequence(QtCore.Qt.Key_Minus)], + 'shortcuts/desktopScreen': [QtGui.QKeySequence(QtCore.Qt.Key_D)], + 'shortcuts/delete': [QtGui.QKeySequence(QtGui.QKeySequence.Delete), QtGui.QKeySequence(QtCore.Qt.Key_Delete)], + 'shortcuts/down': [QtGui.QKeySequence(QtCore.Qt.Key_Down)], + 'shortcuts/editSong': [], + 'shortcuts/escapeItem': [QtGui.QKeySequence(QtCore.Qt.Key_Escape)], + 'shortcuts/expand': [QtGui.QKeySequence(QtCore.Qt.Key_Plus)], + 'shortcuts/exportThemeItem': [], + 'shortcuts/fileNewItem': [QtGui.QKeySequence(QtGui.QKeySequence.New), + QtGui.QKeySequence(QtCore.Qt.CTRL + QtCore.Qt.Key_N)], + 'shortcuts/fileSaveAsItem': [QtGui.QKeySequence(QtGui.QKeySequence.SaveAs), + QtGui.QKeySequence(QtCore.Qt.CTRL + QtCore.Qt.SHIFT + QtCore.Qt.Key_S)], + 'shortcuts/fileExitItem': [QtGui.QKeySequence(QtGui.QKeySequence.Quit), + QtGui.QKeySequence(QtCore.Qt.ALT + QtCore.Qt.Key_F4)], + 'shortcuts/fileSaveItem': [QtGui.QKeySequence(QtGui.QKeySequence.Save), + QtGui.QKeySequence(QtCore.Qt.CTRL + QtCore.Qt.Key_S)], + 'shortcuts/fileOpenItem': [QtGui.QKeySequence(QtGui.QKeySequence.Open), + QtGui.QKeySequence(QtCore.Qt.CTRL + QtCore.Qt.Key_O)], + 'shortcuts/goLive': [], + 'shortcuts/importThemeItem': [], + 'shortcuts/importBibleItem': [], + 'shortcuts/listViewBiblesDeleteItem': [QtGui.QKeySequence(QtGui.QKeySequence.Delete), + QtGui.QKeySequence(QtCore.Qt.Key_Delete)], + 'shortcuts/listViewBiblesPreviewItem': [QtGui.QKeySequence(QtCore.Qt.Key_Return), + QtGui.QKeySequence(QtCore.Qt.Key_Enter)], + 'shortcuts/listViewBiblesLiveItem': [QtGui.QKeySequence(QtCore.Qt.SHIFT + QtCore.Qt.Key_Return), + QtGui.QKeySequence(QtCore.Qt.SHIFT + QtCore.Qt.Key_Enter)], + 'shortcuts/listViewBiblesServiceItem': [QtGui.QKeySequence(QtCore.Qt.Key_Plus), + QtGui.QKeySequence(QtCore.Qt.Key_Equal)], + 'shortcuts/listViewCustomDeleteItem': [QtGui.QKeySequence(QtGui.QKeySequence.Delete), + QtGui.QKeySequence(QtCore.Qt.Key_Delete)], + 'shortcuts/listViewCustomPreviewItem': [QtGui.QKeySequence(QtCore.Qt.Key_Return), + QtGui.QKeySequence(QtCore.Qt.Key_Enter)], + 'shortcuts/listViewCustomLiveItem': [QtGui.QKeySequence(QtCore.Qt.SHIFT + QtCore.Qt.Key_Return), + QtGui.QKeySequence(QtCore.Qt.SHIFT + QtCore.Qt.Key_Enter)], + 'shortcuts/listViewCustomServiceItem': [QtGui.QKeySequence(QtCore.Qt.Key_Plus), + QtGui.QKeySequence(QtCore.Qt.Key_Equal)], + 'shortcuts/listViewImagesDeleteItem': [QtGui.QKeySequence(QtGui.QKeySequence.Delete), + QtGui.QKeySequence(QtCore.Qt.Key_Delete)], + 'shortcuts/listViewImagesPreviewItem': [QtGui.QKeySequence(QtCore.Qt.Key_Return), + QtGui.QKeySequence(QtCore.Qt.Key_Enter)], + 'shortcuts/listViewImagesLiveItem': [QtGui.QKeySequence(QtCore.Qt.SHIFT + QtCore.Qt.Key_Return), + QtGui.QKeySequence(QtCore.Qt.SHIFT + QtCore.Qt.Key_Enter)], + 'shortcuts/listViewImagesServiceItem': [QtGui.QKeySequence(QtCore.Qt.Key_Plus), + QtGui.QKeySequence(QtCore.Qt.Key_Equal)], + 'shortcuts/listViewMediaDeleteItem': [QtGui.QKeySequence(QtGui.QKeySequence.Delete), + QtGui.QKeySequence(QtCore.Qt.Key_Delete)], + 'shortcuts/listViewMediaPreviewItem': [QtGui.QKeySequence(QtCore.Qt.Key_Return), + QtGui.QKeySequence(QtCore.Qt.Key_Enter)], + 'shortcuts/listViewMediaLiveItem': [QtGui.QKeySequence(QtCore.Qt.SHIFT + QtCore.Qt.Key_Return), + QtGui.QKeySequence(QtCore.Qt.SHIFT + QtCore.Qt.Key_Enter)], + 'shortcuts/listViewMediaServiceItem': [QtGui.QKeySequence(QtCore.Qt.Key_Plus), + QtGui.QKeySequence(QtCore.Qt.Key_Equal)], + 'shortcuts/listViewPresentationsDeleteItem': [QtGui.QKeySequence(QtGui.QKeySequence.Delete), + QtGui.QKeySequence(QtCore.Qt.Key_Delete)], + 'shortcuts/listViewPresentationsPreviewItem': [QtGui.QKeySequence(QtCore.Qt.Key_Return), + QtGui.QKeySequence(QtCore.Qt.Key_Enter)], + 'shortcuts/listViewPresentationsLiveItem': [QtGui.QKeySequence(QtCore.Qt.SHIFT + QtCore.Qt.Key_Return), + QtGui.QKeySequence(QtCore.Qt.SHIFT + QtCore.Qt.Key_Enter)], + 'shortcuts/listViewPresentationsServiceItem': [QtGui.QKeySequence(QtCore.Qt.Key_Plus), + QtGui.QKeySequence(QtCore.Qt.Key_Equal)], + 'shortcuts/listViewSongsDeleteItem': [QtGui.QKeySequence(QtGui.QKeySequence.Delete), + QtGui.QKeySequence(QtCore.Qt.Key_Delete)], + 'shortcuts/listViewSongsPreviewItem': [QtGui.QKeySequence(QtCore.Qt.Key_Return), + QtGui.QKeySequence(QtCore.Qt.Key_Enter)], + 'shortcuts/listViewSongsLiveItem': [QtGui.QKeySequence(QtCore.Qt.SHIFT + QtCore.Qt.Key_Return), + QtGui.QKeySequence(QtCore.Qt.SHIFT + QtCore.Qt.Key_Enter)], + 'shortcuts/listViewSongsServiceItem': [QtGui.QKeySequence(QtCore.Qt.Key_Plus), + QtGui.QKeySequence(QtCore.Qt.Key_Equal)], + 'shortcuts/lockPanel': [], + 'shortcuts/modeDefaultItem': [], + 'shortcuts/modeLiveItem': [], + 'shortcuts/make_live': [QtGui.QKeySequence(QtCore.Qt.Key_Return), QtGui.QKeySequence(QtCore.Qt.Key_Enter)], + 'shortcuts/moveUp': [QtGui.QKeySequence(QtCore.Qt.Key_PageUp)], + 'shortcuts/moveTop': [QtGui.QKeySequence(QtCore.Qt.Key_Home)], + 'shortcuts/modeSetupItem': [], + 'shortcuts/moveBottom': [QtGui.QKeySequence(QtCore.Qt.Key_End)], + 'shortcuts/moveDown': [QtGui.QKeySequence(QtCore.Qt.Key_PageDown)], + 'shortcuts/nextTrackItem': [], + 'shortcuts/nextItem_live': [QtGui.QKeySequence(QtCore.Qt.Key_Down), QtGui.QKeySequence(QtCore.Qt.Key_PageDown)], + 'shortcuts/nextItem_preview': [QtGui.QKeySequence(QtCore.Qt.Key_Down), + QtGui.QKeySequence(QtCore.Qt.Key_PageDown)], + 'shortcuts/nextService': [QtGui.QKeySequence(QtCore.Qt.Key_Right)], + 'shortcuts/newService': [], + 'shortcuts/offlineHelpItem': [QtGui.QKeySequence(QtGui.QKeySequence.HelpContents)], + 'shortcuts/onlineHelpItem': [QtGui.QKeySequence(QtGui.QKeySequence.HelpContents), + QtGui.QKeySequence(QtCore.Qt.ALT + QtCore.Qt.Key_F1)], + 'shortcuts/openService': [], + 'shortcuts/saveService': [], + 'shortcuts/previousItem_live': [QtGui.QKeySequence(QtCore.Qt.Key_Up), QtGui.QKeySequence(QtCore.Qt.Key_PageUp)], + 'shortcuts/playbackPause': [], + 'shortcuts/playbackPlay': [], + 'shortcuts/playbackStop': [], + 'shortcuts/playSlidesLoop': [], + 'shortcuts/playSlidesOnce': [], + 'shortcuts/previousService': [QtGui.QKeySequence(QtCore.Qt.Key_Left)], + 'shortcuts/previousItem_preview': [QtGui.QKeySequence(QtCore.Qt.Key_Up), + QtGui.QKeySequence(QtCore.Qt.Key_PageUp)], + 'shortcuts/printServiceItem': [QtGui.QKeySequence(QtGui.QKeySequence.Print), + QtGui.QKeySequence(QtCore.Qt.CTRL + QtCore.Qt.Key_P)], + 'shortcuts/songExportItem': [], + 'shortcuts/songUsageStatus': [QtGui.QKeySequence(QtCore.Qt.Key_F4)], + 'shortcuts/searchShortcut': [QtGui.QKeySequence(QtGui.QKeySequence.Find), + QtGui.QKeySequence(QtCore.Qt.CTRL + QtCore.Qt.Key_F)], + 'shortcuts/settingsShortcutsItem': [], + 'shortcuts/settingsImportItem': [], + 'shortcuts/settingsPluginListItem': [QtGui.QKeySequence(QtCore.Qt.ALT + QtCore.Qt.Key_F7)], + 'shortcuts/songUsageDelete': [], + 'shortcuts/settingsConfigureItem': [QtGui.QKeySequence(QtGui.QKeySequence.Preferences)], + 'shortcuts/shortcutAction_B': [QtGui.QKeySequence(QtCore.Qt.Key_B)], + 'shortcuts/shortcutAction_C': [QtGui.QKeySequence(QtCore.Qt.Key_C)], + 'shortcuts/shortcutAction_E': [QtGui.QKeySequence(QtCore.Qt.Key_E)], + 'shortcuts/shortcutAction_I': [QtGui.QKeySequence(QtCore.Qt.Key_I)], + 'shortcuts/shortcutAction_O': [QtGui.QKeySequence(QtCore.Qt.Key_O)], + 'shortcuts/shortcutAction_P': [QtGui.QKeySequence(QtCore.Qt.Key_P)], + 'shortcuts/shortcutAction_V': [QtGui.QKeySequence(QtCore.Qt.Key_V)], + 'shortcuts/shortcutAction_0': [QtGui.QKeySequence(QtCore.Qt.Key_0)], + 'shortcuts/shortcutAction_1': [QtGui.QKeySequence(QtCore.Qt.Key_1)], + 'shortcuts/shortcutAction_2': [QtGui.QKeySequence(QtCore.Qt.Key_2)], + 'shortcuts/shortcutAction_3': [QtGui.QKeySequence(QtCore.Qt.Key_3)], + 'shortcuts/shortcutAction_4': [QtGui.QKeySequence(QtCore.Qt.Key_4)], + 'shortcuts/shortcutAction_5': [QtGui.QKeySequence(QtCore.Qt.Key_5)], + 'shortcuts/shortcutAction_6': [QtGui.QKeySequence(QtCore.Qt.Key_6)], + 'shortcuts/shortcutAction_7': [QtGui.QKeySequence(QtCore.Qt.Key_7)], + 'shortcuts/shortcutAction_8': [QtGui.QKeySequence(QtCore.Qt.Key_8)], + 'shortcuts/shortcutAction_9': [QtGui.QKeySequence(QtCore.Qt.Key_9)], + 'shortcuts/settingsExportItem': [], + 'shortcuts/songUsageReport': [], + 'shortcuts/songImportItem': [], + 'shortcuts/themeScreen': [QtGui.QKeySequence(QtCore.Qt.Key_T)], + 'shortcuts/toolsReindexItem': [], + 'shortcuts/toolsFindDuplicates': [], + 'shortcuts/toolsAlertItem': [QtGui.QKeySequence(QtCore.Qt.Key_F7)], + 'shortcuts/toolsFirstTimeWizard': [], + 'shortcuts/toolsOpenDataFolder': [], + 'shortcuts/toolsAddToolItem': [], + 'shortcuts/updateThemeImages': [], + 'shortcuts/up': [QtGui.QKeySequence(QtCore.Qt.Key_Up)], + 'shortcuts/viewProjectorManagerItem': [QtGui.QKeySequence(QtCore.Qt.Key_F6)], + 'shortcuts/viewThemeManagerItem': [QtGui.QKeySequence(QtCore.Qt.Key_F10)], + 'shortcuts/viewMediaManagerItem': [QtGui.QKeySequence(QtCore.Qt.Key_F8)], + 'shortcuts/viewPreviewPanel': [QtGui.QKeySequence(QtCore.Qt.Key_F11)], + 'shortcuts/viewLivePanel': [QtGui.QKeySequence(QtCore.Qt.Key_F12)], + 'shortcuts/viewServiceManagerItem': [QtGui.QKeySequence(QtCore.Qt.Key_F9)], + 'shortcuts/webSiteItem': [] + }) def get_default_value(self, key): """ diff --git a/openlp/core/common/uistrings.py b/openlp/core/common/uistrings.py index 5b230baa6..3f221ab08 100644 --- a/openlp/core/common/uistrings.py +++ b/openlp/core/common/uistrings.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # diff --git a/openlp/core/lib/__init__.py b/openlp/core/lib/__init__.py index a6a3c6efe..6e62bbf9c 100644 --- a/openlp/core/lib/__init__.py +++ b/openlp/core/lib/__init__.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # diff --git a/openlp/core/lib/colorbutton.py b/openlp/core/lib/colorbutton.py index 71ed5c489..ebb093581 100644 --- a/openlp/core/lib/colorbutton.py +++ b/openlp/core/lib/colorbutton.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # diff --git a/openlp/core/lib/db.py b/openlp/core/lib/db.py index 7b8b11296..b49539080 100644 --- a/openlp/core/lib/db.py +++ b/openlp/core/lib/db.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # diff --git a/openlp/core/lib/dockwidget.py b/openlp/core/lib/dockwidget.py index b02e3291a..4a8217af0 100644 --- a/openlp/core/lib/dockwidget.py +++ b/openlp/core/lib/dockwidget.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # diff --git a/openlp/core/lib/exceptions.py b/openlp/core/lib/exceptions.py index 46c836965..59c9e5b34 100644 --- a/openlp/core/lib/exceptions.py +++ b/openlp/core/lib/exceptions.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # diff --git a/openlp/core/lib/filedialog.py b/openlp/core/lib/filedialog.py index a4e612ff6..823567a37 100644 --- a/openlp/core/lib/filedialog.py +++ b/openlp/core/lib/filedialog.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # diff --git a/openlp/core/lib/formattingtags.py b/openlp/core/lib/formattingtags.py index 3b676ccf9..9a3b0a8c9 100644 --- a/openlp/core/lib/formattingtags.py +++ b/openlp/core/lib/formattingtags.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # diff --git a/openlp/core/lib/htmlbuilder.py b/openlp/core/lib/htmlbuilder.py index 942a8d93e..812680027 100644 --- a/openlp/core/lib/htmlbuilder.py +++ b/openlp/core/lib/htmlbuilder.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # diff --git a/openlp/core/lib/imagemanager.py b/openlp/core/lib/imagemanager.py index 5ca9852ee..0d0903a3b 100644 --- a/openlp/core/lib/imagemanager.py +++ b/openlp/core/lib/imagemanager.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # diff --git a/openlp/core/lib/listwidgetwithdnd.py b/openlp/core/lib/listwidgetwithdnd.py index c68515d1d..43ec741d0 100644 --- a/openlp/core/lib/listwidgetwithdnd.py +++ b/openlp/core/lib/listwidgetwithdnd.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # diff --git a/openlp/core/lib/mediamanageritem.py b/openlp/core/lib/mediamanageritem.py index 37d2705af..04df1d38a 100644 --- a/openlp/core/lib/mediamanageritem.py +++ b/openlp/core/lib/mediamanageritem.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # diff --git a/openlp/core/lib/plugin.py b/openlp/core/lib/plugin.py index 24b16f7a0..adeacd81b 100644 --- a/openlp/core/lib/plugin.py +++ b/openlp/core/lib/plugin.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # diff --git a/openlp/core/lib/pluginmanager.py b/openlp/core/lib/pluginmanager.py index eb87e6aaa..598c7c5d1 100644 --- a/openlp/core/lib/pluginmanager.py +++ b/openlp/core/lib/pluginmanager.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # diff --git a/openlp/core/lib/projector/__init__.py b/openlp/core/lib/projector/__init__.py index 873bbfa2d..0175a2749 100644 --- a/openlp/core/lib/projector/__init__.py +++ b/openlp/core/lib/projector/__init__.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # diff --git a/openlp/core/lib/projector/constants.py b/openlp/core/lib/projector/constants.py index b7f8afe99..6bfc88a6f 100644 --- a/openlp/core/lib/projector/constants.py +++ b/openlp/core/lib/projector/constants.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # diff --git a/openlp/core/lib/projector/db.py b/openlp/core/lib/projector/db.py index 3d8955ff8..670c9e31b 100644 --- a/openlp/core/lib/projector/db.py +++ b/openlp/core/lib/projector/db.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # diff --git a/openlp/core/lib/projector/pjlink1.py b/openlp/core/lib/projector/pjlink1.py index 6320f32bf..a82cc80be 100644 --- a/openlp/core/lib/projector/pjlink1.py +++ b/openlp/core/lib/projector/pjlink1.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # diff --git a/openlp/core/lib/renderer.py b/openlp/core/lib/renderer.py index 74922b78d..5273493ed 100644 --- a/openlp/core/lib/renderer.py +++ b/openlp/core/lib/renderer.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # diff --git a/openlp/core/lib/screen.py b/openlp/core/lib/screen.py index 2b8883507..819ba9763 100644 --- a/openlp/core/lib/screen.py +++ b/openlp/core/lib/screen.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # diff --git a/openlp/core/lib/searchedit.py b/openlp/core/lib/searchedit.py index c657cef1d..0cdeb271a 100644 --- a/openlp/core/lib/searchedit.py +++ b/openlp/core/lib/searchedit.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # diff --git a/openlp/core/lib/serviceitem.py b/openlp/core/lib/serviceitem.py index c99229f7a..8410d4d28 100644 --- a/openlp/core/lib/serviceitem.py +++ b/openlp/core/lib/serviceitem.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # diff --git a/openlp/core/lib/settingstab.py b/openlp/core/lib/settingstab.py index d5d07b26f..fb7da0e14 100644 --- a/openlp/core/lib/settingstab.py +++ b/openlp/core/lib/settingstab.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # diff --git a/openlp/core/lib/spelltextedit.py b/openlp/core/lib/spelltextedit.py index 5b01d6dcd..3b97323af 100644 --- a/openlp/core/lib/spelltextedit.py +++ b/openlp/core/lib/spelltextedit.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # diff --git a/openlp/core/lib/theme.py b/openlp/core/lib/theme.py index 54c897f15..0ef0065a7 100644 --- a/openlp/core/lib/theme.py +++ b/openlp/core/lib/theme.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # diff --git a/openlp/core/lib/toolbar.py b/openlp/core/lib/toolbar.py index 373e88389..d6f896a17 100644 --- a/openlp/core/lib/toolbar.py +++ b/openlp/core/lib/toolbar.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # diff --git a/openlp/core/lib/treewidgetwithdnd.py b/openlp/core/lib/treewidgetwithdnd.py index 48055090c..c49fc144e 100644 --- a/openlp/core/lib/treewidgetwithdnd.py +++ b/openlp/core/lib/treewidgetwithdnd.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # diff --git a/openlp/core/lib/ui.py b/openlp/core/lib/ui.py index bd37e4dfa..402e4ad34 100644 --- a/openlp/core/lib/ui.py +++ b/openlp/core/lib/ui.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # diff --git a/openlp/core/ui/__init__.py b/openlp/core/ui/__init__.py index 9f803e921..82426539b 100644 --- a/openlp/core/ui/__init__.py +++ b/openlp/core/ui/__init__.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # diff --git a/openlp/core/ui/aboutdialog.py b/openlp/core/ui/aboutdialog.py index f28e3772f..df821e15e 100644 --- a/openlp/core/ui/aboutdialog.py +++ b/openlp/core/ui/aboutdialog.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # @@ -298,8 +298,8 @@ class UiAboutDialog(object): self.about_notebook.setTabText(self.about_notebook.indexOf(self.credits_tab), translate('OpenLP.AboutForm', 'Credits')) copyright_note = translate('OpenLP.AboutForm', - 'Copyright \xa9 2004-2015 %s\n' - 'Portions copyright \xa9 2004-2015 %s') % \ + 'Copyright \xa9 2004-2016 %s\n' + 'Portions copyright \xa9 2004-2016 %s') % \ ('Raoul Snyman', 'Tim Bentley, Gerald Britton, Jonathan Corwin, Samuel Findlay, ' 'Michael Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, ' diff --git a/openlp/core/ui/aboutform.py b/openlp/core/ui/aboutform.py index 67e0a971f..d8defe322 100644 --- a/openlp/core/ui/aboutform.py +++ b/openlp/core/ui/aboutform.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # diff --git a/openlp/core/ui/advancedtab.py b/openlp/core/ui/advancedtab.py index 898a3912e..4421b432f 100644 --- a/openlp/core/ui/advancedtab.py +++ b/openlp/core/ui/advancedtab.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # diff --git a/openlp/core/ui/exceptiondialog.py b/openlp/core/ui/exceptiondialog.py index 2f3339a29..9b835ea81 100644 --- a/openlp/core/ui/exceptiondialog.py +++ b/openlp/core/ui/exceptiondialog.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # diff --git a/openlp/core/ui/exceptionform.py b/openlp/core/ui/exceptionform.py index cc6362290..d7ddc9fc4 100644 --- a/openlp/core/ui/exceptionform.py +++ b/openlp/core/ui/exceptionform.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # diff --git a/openlp/core/ui/filerenamedialog.py b/openlp/core/ui/filerenamedialog.py index 19550215d..ede60bcfb 100644 --- a/openlp/core/ui/filerenamedialog.py +++ b/openlp/core/ui/filerenamedialog.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # diff --git a/openlp/core/ui/filerenameform.py b/openlp/core/ui/filerenameform.py index 7d84a97d2..d1760ced9 100644 --- a/openlp/core/ui/filerenameform.py +++ b/openlp/core/ui/filerenameform.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # diff --git a/openlp/core/ui/firsttimeform.py b/openlp/core/ui/firsttimeform.py index e5ea662ee..0d7c129bf 100644 --- a/openlp/core/ui/firsttimeform.py +++ b/openlp/core/ui/firsttimeform.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # diff --git a/openlp/core/ui/firsttimelanguagedialog.py b/openlp/core/ui/firsttimelanguagedialog.py index 8adf72b4e..dd1389ba2 100644 --- a/openlp/core/ui/firsttimelanguagedialog.py +++ b/openlp/core/ui/firsttimelanguagedialog.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # diff --git a/openlp/core/ui/firsttimelanguageform.py b/openlp/core/ui/firsttimelanguageform.py index b1bd7e7f4..682cf4825 100644 --- a/openlp/core/ui/firsttimelanguageform.py +++ b/openlp/core/ui/firsttimelanguageform.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # diff --git a/openlp/core/ui/firsttimewizard.py b/openlp/core/ui/firsttimewizard.py index ec2acf881..cbec14a40 100644 --- a/openlp/core/ui/firsttimewizard.py +++ b/openlp/core/ui/firsttimewizard.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # diff --git a/openlp/core/ui/formattingtagcontroller.py b/openlp/core/ui/formattingtagcontroller.py index 6c9d95190..b56f5009c 100644 --- a/openlp/core/ui/formattingtagcontroller.py +++ b/openlp/core/ui/formattingtagcontroller.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # diff --git a/openlp/core/ui/formattingtagdialog.py b/openlp/core/ui/formattingtagdialog.py index 3e14d4b57..19412921d 100644 --- a/openlp/core/ui/formattingtagdialog.py +++ b/openlp/core/ui/formattingtagdialog.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # diff --git a/openlp/core/ui/formattingtagform.py b/openlp/core/ui/formattingtagform.py index bd2a32978..fa53315f1 100644 --- a/openlp/core/ui/formattingtagform.py +++ b/openlp/core/ui/formattingtagform.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # diff --git a/openlp/core/ui/generaltab.py b/openlp/core/ui/generaltab.py index 47a6a9594..28f2b0362 100644 --- a/openlp/core/ui/generaltab.py +++ b/openlp/core/ui/generaltab.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # @@ -317,6 +317,8 @@ class GeneralTab(SettingsTab): self.custom_Y_value_edit.value(), self.custom_width_value_edit.value(), self.custom_height_value_edit.value()) + self.screens.override['number'] = self.screens.which_screen(self.screens.override['size']) + self.screens.override['primary'] = (self.screens.desktop.primaryScreen() == self.screens.override['number']) if self.override_radio_button.isChecked(): self.screens.set_override_display() else: diff --git a/openlp/core/ui/listpreviewwidget.py b/openlp/core/ui/listpreviewwidget.py index 17c333f16..fb6481e56 100644 --- a/openlp/core/ui/listpreviewwidget.py +++ b/openlp/core/ui/listpreviewwidget.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # diff --git a/openlp/core/ui/maindisplay.py b/openlp/core/ui/maindisplay.py index 05ab222b9..bc2a01ed4 100644 --- a/openlp/core/ui/maindisplay.py +++ b/openlp/core/ui/maindisplay.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # @@ -39,6 +39,13 @@ from openlp.core.lib import ServiceItem, ImageSource, ScreenList, build_html, ex from openlp.core.lib.theme import BackgroundType from openlp.core.ui import HideMode, AlertLocation +if is_macosx(): + from ctypes import pythonapi, c_void_p, c_char_p, py_object + + from sip import voidptr + from objc import objc_object + from AppKit import NSMainMenuWindowLevel, NSWindowCollectionBehaviorManaged + log = logging.getLogger(__name__) OPAQUE_STYLESHEET = """ @@ -154,15 +161,30 @@ class MainDisplay(OpenLPMixin, Display, RegistryProperties): # regressions on other platforms. if is_macosx(): window_flags = QtCore.Qt.FramelessWindowHint | QtCore.Qt.Window - # For primary screen ensure it stays above the OS X dock - # and menu bar - if self.screens.current['primary']: - self.setWindowState(QtCore.Qt.WindowFullScreen) - else: - window_flags |= QtCore.Qt.WindowStaysOnTopHint self.setWindowFlags(window_flags) self.setAttribute(QtCore.Qt.WA_DeleteOnClose) self.set_transparency(False) + if is_macosx(): + if self.is_live: + # Get a pointer to the underlying NSView + try: + nsview_pointer = self.winId().ascapsule() + except: + nsview_pointer = voidptr(self.winId()).ascapsule() + # Set PyCapsule name so pyobjc will accept it + pythonapi.PyCapsule_SetName.restype = c_void_p + pythonapi.PyCapsule_SetName.argtypes = [py_object, c_char_p] + pythonapi.PyCapsule_SetName(nsview_pointer, c_char_p(b"objc.__object__")) + # Covert the NSView pointer into a pyobjc NSView object + self.pyobjc_nsview = objc_object(cobject=nsview_pointer) + # Set the window level so that the MainDisplay is above the menu bar and dock + self.pyobjc_nsview.window().setLevel_(NSMainMenuWindowLevel + 2) + # Set the collection behavior so the window is visible when Mission Control is activated + self.pyobjc_nsview.window().setCollectionBehavior_(NSWindowCollectionBehaviorManaged) + if self.screens.current['primary']: + # Connect focusWindowChanged signal so we can change the window level when the display is not in + # focus on the primary screen + self.application.focusWindowChanged.connect(self.change_window_level) if self.is_live: Registry().register_function('live_display_hide', self.hide_display) Registry().register_function('live_display_show', self.show_display) @@ -186,6 +208,12 @@ class MainDisplay(OpenLPMixin, Display, RegistryProperties): Remove registered function on close. """ if self.is_live: + if is_macosx(): + # Block signals so signal we are disconnecting can't get called while we disconnect it + self.blockSignals(True) + if self.screens.current['primary']: + self.application.focusWindowChanged.disconnect() + self.blockSignals(False) Registry().remove_function('live_display_hide', self.hide_display) Registry().remove_function('live_display_show', self.show_display) Registry().remove_function('update_display_css', self.css_changed) @@ -500,6 +528,36 @@ class MainDisplay(OpenLPMixin, Display, RegistryProperties): self.setCursor(QtCore.Qt.ArrowCursor) self.frame.evaluateJavaScript('document.body.style.cursor = "auto"') + def change_window_level(self, window): + """ + Changes the display window level on Mac OS X so that the main window can be brought into focus but still allow + the main display to be above the menu bar and dock when it in focus. + + :param window: Window from our application that focus changed to or None if outside our application + """ + if is_macosx(): + if window: + # Get different window ids' as int's + try: + window_id = window.winId().__int__() + main_window_id = self.main_window.winId().__int__() + self_id = self.winId().__int__() + except: + return + # If the passed window has the same id as our window make sure the display has the proper level and + # collection behavior. + if window_id == self_id: + self.pyobjc_nsview.window().setLevel_(NSMainMenuWindowLevel + 2) + self.pyobjc_nsview.window().setCollectionBehavior_(NSWindowCollectionBehaviorManaged) + # Else set the displays window level back to normal since we are trying to focus a window other than + # the display. + else: + self.pyobjc_nsview.window().setLevel_(0) + self.pyobjc_nsview.window().setCollectionBehavior_(NSWindowCollectionBehaviorManaged) + # If we are trying to focus the main window raise it now to complete the focus change. + if window_id == main_window_id: + self.main_window.raise_() + class AudioPlayer(OpenLPMixin, QtCore.QObject): """ diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index 33a12866a..aed44468e 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # @@ -1102,7 +1102,8 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow, RegistryProperties): QtWidgets.QMessageBox.StandardButtons(QtWidgets.QMessageBox.Close | QtWidgets.QMessageBox.Cancel), self) - msg_box.setButtonText(QtWidgets.QMessageBox.Close, translate('OpenLP.MainWindow', '&Exit OpenLP')) + close_button = msg_box.button(QtWidgets.QMessageBox.Close) + close_button.setText(translate('OpenLP.MainWindow', '&Exit OpenLP')) msg_box.setDefaultButton(QtWidgets.QMessageBox.Close) if msg_box.exec() == QtWidgets.QMessageBox.Close: self.clean_up() diff --git a/openlp/core/ui/media/__init__.py b/openlp/core/ui/media/__init__.py index a6cb8aae6..ecd4b98bd 100644 --- a/openlp/core/ui/media/__init__.py +++ b/openlp/core/ui/media/__init__.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # diff --git a/openlp/core/ui/media/mediacontroller.py b/openlp/core/ui/media/mediacontroller.py index 9b0185add..343ce0dd4 100644 --- a/openlp/core/ui/media/mediacontroller.py +++ b/openlp/core/ui/media/mediacontroller.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # diff --git a/openlp/core/ui/media/mediaplayer.py b/openlp/core/ui/media/mediaplayer.py index 740d200f3..b25916372 100644 --- a/openlp/core/ui/media/mediaplayer.py +++ b/openlp/core/ui/media/mediaplayer.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # diff --git a/openlp/core/ui/media/playertab.py b/openlp/core/ui/media/playertab.py index a47852510..3db5e06b4 100644 --- a/openlp/core/ui/media/playertab.py +++ b/openlp/core/ui/media/playertab.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # @@ -22,6 +22,7 @@ """ The :mod:`~openlp.core.ui.media.playertab` module holds the configuration tab for the media stuff. """ +import platform from PyQt5 import QtCore, QtWidgets from openlp.core.common import Registry, Settings, UiStrings, translate @@ -250,4 +251,9 @@ class PlayerTab(SettingsTab): if player.available: checkbox.setText(player.display_name) else: - checkbox.setText(translate('OpenLP.PlayerTab', '%s (unavailable)') % player.display_name) + checkbox_text = translate('OpenLP.PlayerTab', '%s (unavailable)') % player.display_name + if player.name == 'vlc': + checkbox_text += ' ' + translate('OpenLP.PlayerTab', + 'NOTE: To use VLC you must install the %s version', + 'Will insert "32bit" or "64bit"') % platform.architecture()[0] + checkbox.setText(checkbox_text) diff --git a/openlp/core/ui/media/vendor/__init__.py b/openlp/core/ui/media/vendor/__init__.py index d3d7681ae..e71278465 100644 --- a/openlp/core/ui/media/vendor/__init__.py +++ b/openlp/core/ui/media/vendor/__init__.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # diff --git a/openlp/core/ui/media/vendor/vlc.py b/openlp/core/ui/media/vendor/vlc.py index f56d3ef56..c571c7f35 100644 --- a/openlp/core/ui/media/vendor/vlc.py +++ b/openlp/core/ui/media/vendor/vlc.py @@ -5,7 +5,7 @@ # Copyright (C) 2009-2012 the VideoLAN team # $Id: $ # -# Authors: Olivier Aubert +# Authors: Olivier Aubert # Jean Brouwers # Geoff Salmon # @@ -43,12 +43,18 @@ import ctypes from ctypes.util import find_library import os import sys +import functools # Used by EventManager in override.py from inspect import getargspec __version__ = "N/A" -build_date = "Wed Jun 25 13:46:01 2014" +build_date = "Thu Nov 5 23:41:43 2015" + +# The libvlc doc states that filenames are expected to be in UTF8, do +# not rely on sys.getfilesystemencoding() which will be confused, +# esp. on windows. +DEFAULT_ENCODING = 'utf-8' if sys.version_info[0] > 2: str = str @@ -60,7 +66,7 @@ if sys.version_info[0] > 2: """Translate string or bytes to bytes. """ if isinstance(s, str): - return s.encode() + return bytes(s, DEFAULT_ENCODING) else: return s @@ -68,7 +74,7 @@ if sys.version_info[0] > 2: """Translate bytes to string. """ if isinstance(b, bytes): - return b.decode(sys.getfilesystemencoding()) + return b.decode(DEFAULT_ENCODING) else: return b else: @@ -81,7 +87,7 @@ else: """Translate string or bytes to bytes. """ if isinstance(s, unicode): - return s.encode(sys.getfilesystemencoding()) + return s.encode(DEFAULT_ENCODING) else: return s @@ -89,7 +95,7 @@ else: """Translate bytes to unicode string. """ if isinstance(b, str): - return unicode(b, sys.getfilesystemencoding()) + return unicode(b, DEFAULT_ENCODING) else: return b @@ -177,6 +183,35 @@ except NameError: # no long in Python 3+ _Ints = int _Seqs = (list, tuple) +# Used for handling *event_manager() methods. +class memoize_parameterless(object): + """Decorator. Caches a parameterless method's return value each time it is called. + + If called later with the same arguments, the cached value is returned + (not reevaluated). + Adapted from https://wiki.python.org/moin/PythonDecoratorLibrary + """ + def __init__(self, func): + self.func = func + self._cache = {} + + def __call__(self, obj): + try: + return self._cache[obj] + except KeyError: + v = self._cache[obj] = self.func(obj) + return v + + def __repr__(self): + """Return the function's docstring. + """ + return self.func.__doc__ + + def __get__(self, obj, objtype): + """Support instance methods. + """ + return functools.partial(self.__call__, obj) + # Default instance. It is used to instanciate classes directly in the # OO-wrapper. _default_instance = None @@ -390,10 +425,20 @@ class EventType(_Enum): 273: 'MediaPlayerLengthChanged', 274: 'MediaPlayerVout', 275: 'MediaPlayerScrambledChanged', + 276: 'MediaPlayerESAdded', + 277: 'MediaPlayerESDeleted', + 278: 'MediaPlayerESSelected', + 279: 'MediaPlayerCorked', + 280: 'MediaPlayerUncorked', + 281: 'MediaPlayerMuted', + 282: 'MediaPlayerUnmuted', + 283: 'MediaPlayerAudioVolume', + 284: 'MediaPlayerAudioDevice', 0x200: 'MediaListItemAdded', 513: 'MediaListWillAddItem', 514: 'MediaListItemDeleted', 515: 'MediaListWillDeleteItem', + 516: 'MediaListEndReached', 0x300: 'MediaListViewItemAdded', 769: 'MediaListViewWillAddItem', 770: 'MediaListViewItemDeleted', @@ -419,6 +464,7 @@ EventType.MediaDiscovererEnded = EventType(1281) EventType.MediaDiscovererStarted = EventType(0x500) EventType.MediaDurationChanged = EventType(2) EventType.MediaFreed = EventType(4) +EventType.MediaListEndReached = EventType(516) EventType.MediaListItemAdded = EventType(0x200) EventType.MediaListItemDeleted = EventType(514) EventType.MediaListPlayerNextItemSet = EventType(1025) @@ -432,13 +478,20 @@ EventType.MediaListWillAddItem = EventType(513) EventType.MediaListWillDeleteItem = EventType(515) EventType.MediaMetaChanged = EventType(0) EventType.MediaParsedChanged = EventType(3) +EventType.MediaPlayerAudioDevice = EventType(284) +EventType.MediaPlayerAudioVolume = EventType(283) EventType.MediaPlayerBackward = EventType(264) EventType.MediaPlayerBuffering = EventType(259) +EventType.MediaPlayerCorked = EventType(279) +EventType.MediaPlayerESAdded = EventType(276) +EventType.MediaPlayerESDeleted = EventType(277) +EventType.MediaPlayerESSelected = EventType(278) EventType.MediaPlayerEncounteredError = EventType(266) EventType.MediaPlayerEndReached = EventType(265) EventType.MediaPlayerForward = EventType(263) EventType.MediaPlayerLengthChanged = EventType(273) EventType.MediaPlayerMediaChanged = EventType(0x100) +EventType.MediaPlayerMuted = EventType(281) EventType.MediaPlayerNothingSpecial = EventType(257) EventType.MediaPlayerOpening = EventType(258) EventType.MediaPlayerPausableChanged = EventType(270) @@ -451,6 +504,8 @@ EventType.MediaPlayerSnapshotTaken = EventType(272) EventType.MediaPlayerStopped = EventType(262) EventType.MediaPlayerTimeChanged = EventType(267) EventType.MediaPlayerTitleChanged = EventType(271) +EventType.MediaPlayerUncorked = EventType(280) +EventType.MediaPlayerUnmuted = EventType(282) EventType.MediaPlayerVout = EventType(274) EventType.MediaStateChanged = EventType(5) EventType.MediaSubItemAdded = EventType(1) @@ -494,15 +549,19 @@ class Meta(_Enum): 20: 'Episode', 21: 'ShowName', 22: 'Actors', + 23: 'AlbumArtist', + 24: 'DiscNumber', } Meta.Actors = Meta(22) Meta.Album = Meta(4) +Meta.AlbumArtist = Meta(23) Meta.Artist = Meta(1) Meta.ArtworkURL = Meta(15) Meta.Copyright = Meta(3) Meta.Date = Meta(8) Meta.Description = Meta(6) Meta.Director = Meta(18) +Meta.DiscNumber = Meta(24) Meta.EncodedBy = Meta(14) Meta.Episode = Meta(20) Meta.Genre = Meta(2) @@ -560,6 +619,40 @@ TrackType.text = TrackType(2) TrackType.unknown = TrackType(-1) TrackType.video = TrackType(1) +class MediaType(_Enum): + '''Media type +See libvlc_media_get_type. + ''' + _enum_names_ = { + 0: 'unknown', + 1: 'file', + 2: 'directory', + 3: 'disc', + 4: 'stream', + 5: 'playlist', + } +MediaType.directory = MediaType(2) +MediaType.disc = MediaType(3) +MediaType.file = MediaType(1) +MediaType.playlist = MediaType(5) +MediaType.stream = MediaType(4) +MediaType.unknown = MediaType(0) + +class MediaParseFlag(_Enum): + '''Parse flags used by libvlc_media_parse_with_options() +See libvlc_media_parse_with_options. + ''' + _enum_names_ = { + 0x00: 'local', + 0x01: 'network', + 0x02: 'local', + 0x04: 'network', + } +MediaParseFlag.local = MediaParseFlag(0x00) +MediaParseFlag.local = MediaParseFlag(0x02) +MediaParseFlag.network = MediaParseFlag(0x01) +MediaParseFlag.network = MediaParseFlag(0x04) + class PlaybackMode(_Enum): '''Defines playback modes for playlist. ''' @@ -730,7 +823,7 @@ class Callback(ctypes.c_void_p): class LogCb(ctypes.c_void_p): """Callback prototype for LibVLC log message handler. \param data data pointer as given to L{libvlc_log_set}() -\param level message level (@ref enum libvlc_log_level) +\param level message level (@ref libvlc_log_level) \param ctx message context (meta-information about the message) \param fmt printf() format string (as defined by ISO C11) \param args variable argument list for the format @@ -739,6 +832,49 @@ class LogCb(ctypes.c_void_p): variable arguments are only valid until the callback returns. """ pass +class MediaOpenCb(ctypes.c_void_p): + """Callback prototype to open a custom bitstream input media. +The same media item can be opened multiple times. Each time, this callback +is invoked. It should allocate and initialize any instance-specific +resources, then store them in *datap. The instance resources can be freed +in the @ref libvlc_media_close_cb callback. +\param opaque private pointer as passed to L{libvlc_media_new_callbacks}() +\param datap storage space for a private data pointer [OUT] +\param sizep byte length of the bitstream or UINT64_MAX if unknown [OUT] +\note For convenience, *datap is initially NULL and *sizep is initially 0. +\return 0 on success, non-zero on error. In case of failure, the other +callbacks will not be invoked and any value stored in *datap and *sizep is +discarded. + """ + pass +class MediaReadCb(ctypes.c_void_p): + """Callback prototype to read data from a custom bitstream input media. +\param opaque private pointer as set by the @ref libvlc_media_open_cb + callback +\param buf start address of the buffer to read data into +\param len bytes length of the buffer +\return strictly positive number of bytes read, 0 on end-of-stream, + or -1 on non-recoverable error +\note If no data is immediately available, then the callback should sleep. +\warning The application is responsible for avoiding deadlock situations. +In particular, the callback should return an error if playback is stopped; +if it does not return, then L{libvlc_media_player_stop}() will never return. + """ + pass +class MediaSeekCb(ctypes.c_void_p): + """Callback prototype to seek a custom bitstream input media. +\param opaque private pointer as set by the @ref libvlc_media_open_cb + callback +\param offset absolute byte offset to seek to +\return 0 on success, -1 on error. + """ + pass +class MediaCloseCb(ctypes.c_void_p): + """Callback prototype to close a custom bitstream input media. +\param opaque private pointer as set by the @ref libvlc_media_open_cb + callback + """ + pass class VideoLockCb(ctypes.c_void_p): """Callback prototype to allocate and lock a picture buffer. Whenever a new video frame needs to be decoded, the lock callback is @@ -796,7 +932,7 @@ the number of bytes per pixel multiplied by the pixel width. Similarly, the number of scanlines must be bigger than of equal to the pixel height. Furthermore, we recommend that pitches and lines be multiple of 32 -to not break assumption that might be made by various optimizations +to not break assumptions that might be held by optimized code in the video decoders, video filters and/or video converters. """ pass @@ -869,18 +1005,57 @@ class CallbackDecorators(object): Callback = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_void_p, ctypes.c_void_p) Callback.__doc__ = '''Callback function notification \param p_event the event triggering the callback - ''' + ''' LogCb = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_void_p, ctypes.c_int, Log_ptr, ctypes.c_char_p, ctypes.c_void_p) LogCb.__doc__ = '''Callback prototype for LibVLC log message handler. \param data data pointer as given to L{libvlc_log_set}() -\param level message level (@ref enum libvlc_log_level) +\param level message level (@ref libvlc_log_level) \param ctx message context (meta-information about the message) \param fmt printf() format string (as defined by ISO C11) \param args variable argument list for the format \note Log message handlers must be thread-safe. \warning The message context pointer, the format string parameters and the variable arguments are only valid until the callback returns. - ''' + ''' + MediaOpenCb = ctypes.CFUNCTYPE(ctypes.POINTER(ctypes.c_int), ctypes.c_void_p, ListPOINTER(ctypes.c_void_p), ctypes.POINTER(ctypes.c_uint64)) + MediaOpenCb.__doc__ = '''Callback prototype to open a custom bitstream input media. +The same media item can be opened multiple times. Each time, this callback +is invoked. It should allocate and initialize any instance-specific +resources, then store them in *datap. The instance resources can be freed +in the @ref libvlc_media_close_cb callback. +\param opaque private pointer as passed to L{libvlc_media_new_callbacks}() +\param datap storage space for a private data pointer [OUT] +\param sizep byte length of the bitstream or UINT64_MAX if unknown [OUT] +\note For convenience, *datap is initially NULL and *sizep is initially 0. +\return 0 on success, non-zero on error. In case of failure, the other +callbacks will not be invoked and any value stored in *datap and *sizep is +discarded. + ''' + MediaReadCb = ctypes.CFUNCTYPE(ctypes.POINTER(ctypes.c_ssize_t), ctypes.c_void_p, ctypes.c_char_p, ctypes.c_size_t) + MediaReadCb.__doc__ = '''Callback prototype to read data from a custom bitstream input media. +\param opaque private pointer as set by the @ref libvlc_media_open_cb + callback +\param buf start address of the buffer to read data into +\param len bytes length of the buffer +\return strictly positive number of bytes read, 0 on end-of-stream, + or -1 on non-recoverable error +\note If no data is immediately available, then the callback should sleep. +\warning The application is responsible for avoiding deadlock situations. +In particular, the callback should return an error if playback is stopped; +if it does not return, then L{libvlc_media_player_stop}() will never return. + ''' + MediaSeekCb = ctypes.CFUNCTYPE(ctypes.POINTER(ctypes.c_int), ctypes.c_void_p, ctypes.c_uint64) + MediaSeekCb.__doc__ = '''Callback prototype to seek a custom bitstream input media. +\param opaque private pointer as set by the @ref libvlc_media_open_cb + callback +\param offset absolute byte offset to seek to +\return 0 on success, -1 on error. + ''' + MediaCloseCb = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_void_p) + MediaCloseCb.__doc__ = '''Callback prototype to close a custom bitstream input media. +\param opaque private pointer as set by the @ref libvlc_media_open_cb + callback + ''' VideoLockCb = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_void_p, ListPOINTER(ctypes.c_void_p)) VideoLockCb.__doc__ = '''Callback prototype to allocate and lock a picture buffer. Whenever a new video frame needs to be decoded, the lock callback is @@ -892,7 +1067,7 @@ planes must be aligned on 32-bytes boundaries. of void pointers, this callback must initialize the array) [OUT] \return a private pointer for the display and unlock callbacks to identify the picture buffers - ''' + ''' VideoUnlockCb = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_void_p, ctypes.c_void_p, ListPOINTER(ctypes.c_void_p)) VideoUnlockCb.__doc__ = '''Callback prototype to unlock a picture buffer. When the video frame decoding is complete, the unlock callback is invoked. @@ -905,7 +1080,7 @@ but before the picture is displayed. callback [IN] \param planes pixel planes as defined by the @ref libvlc_video_lock_cb callback (this parameter is only for convenience) [IN] - ''' + ''' VideoDisplayCb = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_void_p, ctypes.c_void_p) VideoDisplayCb.__doc__ = '''Callback prototype to display a picture. When the video frame needs to be shown, as determined by the media playback @@ -913,7 +1088,7 @@ clock, the display callback is invoked. \param opaque private pointer as passed to L{libvlc_video_set_callbacks}() [IN] \param picture private pointer returned from the @ref libvlc_video_lock_cb callback [IN] - ''' + ''' VideoFormatCb = ctypes.CFUNCTYPE(ctypes.POINTER(ctypes.c_uint), ListPOINTER(ctypes.c_void_p), ctypes.c_char_p, ctypes.POINTER(ctypes.c_uint), ctypes.POINTER(ctypes.c_uint), ctypes.POINTER(ctypes.c_uint), ctypes.POINTER(ctypes.c_uint)) VideoFormatCb.__doc__ = '''Callback prototype to configure picture buffers format. This callback gets the format of the video as output by the video decoder @@ -935,49 +1110,49 @@ the number of bytes per pixel multiplied by the pixel width. Similarly, the number of scanlines must be bigger than of equal to the pixel height. Furthermore, we recommend that pitches and lines be multiple of 32 -to not break assumption that might be made by various optimizations +to not break assumptions that might be held by optimized code in the video decoders, video filters and/or video converters. - ''' + ''' VideoCleanupCb = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_void_p) VideoCleanupCb.__doc__ = '''Callback prototype to configure picture buffers format. \param opaque private pointer as passed to L{libvlc_video_set_callbacks}() (and possibly modified by @ref libvlc_video_format_cb) [IN] - ''' + ''' AudioPlayCb = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_void_p, ctypes.c_void_p, ctypes.c_uint, ctypes.c_int64) AudioPlayCb.__doc__ = '''Callback prototype for audio playback. \param data data pointer as passed to L{libvlc_audio_set_callbacks}() [IN] \param samples pointer to the first audio sample to play back [IN] \param count number of audio samples to play back \param pts expected play time stamp (see libvlc_delay()) - ''' + ''' AudioPauseCb = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_void_p, ctypes.c_int64) AudioPauseCb.__doc__ = '''Callback prototype for audio pause. \note The pause callback is never called if the audio is already paused. \param data data pointer as passed to L{libvlc_audio_set_callbacks}() [IN] \param pts time stamp of the pause request (should be elapsed already) - ''' + ''' AudioResumeCb = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_void_p, ctypes.c_int64) AudioResumeCb.__doc__ = '''Callback prototype for audio resumption (i.e. restart from pause). \note The resume callback is never called if the audio is not paused. \param data data pointer as passed to L{libvlc_audio_set_callbacks}() [IN] \param pts time stamp of the resumption request (should be elapsed already) - ''' + ''' AudioFlushCb = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_void_p, ctypes.c_int64) AudioFlushCb.__doc__ = '''Callback prototype for audio buffer flush (i.e. discard all pending buffers and stop playback as soon as possible). \param data data pointer as passed to L{libvlc_audio_set_callbacks}() [IN] - ''' + ''' AudioDrainCb = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_void_p) AudioDrainCb.__doc__ = '''Callback prototype for audio buffer drain (i.e. wait for pending buffers to be played). \param data data pointer as passed to L{libvlc_audio_set_callbacks}() [IN] - ''' + ''' AudioSetVolumeCb = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_void_p, ctypes.c_float, ctypes.c_bool) AudioSetVolumeCb.__doc__ = '''Callback prototype for audio volume change. \param data data pointer as passed to L{libvlc_audio_set_callbacks}() [IN] \param volume software volume (1. = nominal, 0. = mute) \param mute muted flag - ''' + ''' AudioSetupCb = ctypes.CFUNCTYPE(ctypes.POINTER(ctypes.c_int), ListPOINTER(ctypes.c_void_p), ctypes.c_char_p, ctypes.POINTER(ctypes.c_uint), ctypes.POINTER(ctypes.c_uint)) AudioSetupCb.__doc__ = '''Callback prototype to setup the audio playback. This is called when the media player needs to create a new audio output. @@ -987,12 +1162,12 @@ This is called when the media player needs to create a new audio output. \param rate sample rate [IN/OUT] \param channels channels count [IN/OUT] \return 0 on success, anything else to skip audio playback - ''' + ''' AudioCleanupCb = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_void_p) AudioCleanupCb.__doc__ = '''Callback prototype for audio playback cleanup. This is called when the media player no longer needs an audio output. \param opaque data pointer as passed to L{libvlc_audio_set_callbacks}() [IN] - ''' + ''' cb = CallbackDecorators # End of generated enum types # @@ -1183,12 +1358,15 @@ class EventUnion(ctypes.Union): ('new_status', ctypes.c_int ), ('media', ctypes.c_void_p ), ('new_state', ctypes.c_uint ), - # Media instance + # FIXME: Media instance + ('new_cache', ctypes.c_float ), ('new_position', ctypes.c_float ), ('new_time', ctypes.c_longlong), ('new_title', ctypes.c_int ), ('new_seekable', ctypes.c_longlong), ('new_pausable', ctypes.c_longlong), + ('new_scrambled', ctypes.c_longlong), + ('new_count', ctypes.c_longlong), # FIXME: Skipped MediaList and MediaListView... ('filename', ctypes.c_char_p ), ('new_length', ctypes.c_longlong), @@ -1239,6 +1417,20 @@ AudioOutputDevice._fields_ = [ # recursive struct ('description', ctypes.c_char_p), ] +class TitleDescription(_Cstruct): + _fields = [ + ('duration', ctypes.c_longlong), + ('name', ctypes.c_char_p), + ('menu', ctypes.c_bool), + ] + +class ChapterDescription(_Cstruct): + _fields = [ + ('time_offset', ctypes.c_longlong), + ('duration', ctypes.c_longlong), + ('name', ctypes.c_char_p), + ] + # End of header.py # class EventManager(_Ctype): @@ -1256,7 +1448,7 @@ class EventManager(_Ctype): @note: Only a single notification can be registered for each event type in an EventManager instance. - + ''' _callback_handler = None @@ -1333,7 +1525,7 @@ class Instance(_Ctype): - a string - a list of strings as first parameters - the parameters given as the constructor parameters (must be strings) - + ''' def __new__(cls, *args): @@ -1384,13 +1576,14 @@ class Instance(_Ctype): local path. If you need more control, directly use media_new_location/media_new_path methods. - Options can be specified as supplementary string parameters, e.g. + Options can be specified as supplementary string parameters, + but note that many options cannot be set at the media level, + and rather at the Instance level. For instance, the marquee + filter must be specified when creating the vlc.Instance or + vlc.MediaPlayer. - C{m = i.media_new('foo.avi', 'sub-filter=marq{marquee=Hello}', 'vout-filter=invert')} - - Alternatively, the options can be added to the media using the Media.add_options method: - - C{m.add_options('foo.avi', 'sub-filter=marq@test{marquee=Hello}', 'video-filter=invert')} + Alternatively, options can be added to the media using the + Media.add_options method (with the same limitation). @param options: optional media option=value strings """ @@ -1450,25 +1643,29 @@ class Instance(_Ctype): return module_description_list(libvlc_video_filter_list_get(self)) + def release(self): '''Decrement the reference count of a libvlc instance, and destroy it if it reaches zero. ''' return libvlc_release(self) + def retain(self): '''Increments the reference count of a libvlc instance. The initial reference count is 1 after L{new}() returns. ''' return libvlc_retain(self) + def add_intf(self, name): '''Try to start a user interface for the libvlc instance. - @param name: interface name, or NULL for default. + @param name: interface name, or None for default. @return: 0 on success, -1 on error. ''' return libvlc_add_intf(self, str_to_bytes(name)) + def set_user_agent(self, name, http): '''Sets the application name. LibVLC passes this as the user agent string when a protocol requires it. @@ -1478,6 +1675,7 @@ class Instance(_Ctype): ''' return libvlc_set_user_agent(self, str_to_bytes(name), str_to_bytes(http)) + def set_app_id(self, id, version, icon): '''Sets some meta-information about the application. See also L{set_user_agent}(). @@ -1488,6 +1686,7 @@ class Instance(_Ctype): ''' return libvlc_set_app_id(self, str_to_bytes(id), str_to_bytes(version), str_to_bytes(icon)) + def log_unset(self): '''Unsets the logging callback for a LibVLC instance. This is rarely needed: the callback is implicitly unset when the instance is destroyed. @@ -1497,6 +1696,7 @@ class Instance(_Ctype): ''' return libvlc_log_unset(self) + def log_set(self, data, p_instance): '''Sets the logging callback for a LibVLC instance. This function is thread-safe: it will wait for any pending callbacks @@ -1507,6 +1707,7 @@ class Instance(_Ctype): ''' return libvlc_log_set(self, data, p_instance) + def log_set_file(self, stream): '''Sets up logging to a file. @param stream: FILE pointer opened for writing (the FILE pointer must remain valid until L{log_unset}()). @@ -1514,6 +1715,7 @@ class Instance(_Ctype): ''' return libvlc_log_set_file(self, stream) + def media_new_location(self, psz_mrl): '''Create a media with a certain given media resource location, for instance a valid URL. @@ -1523,18 +1725,20 @@ class Instance(_Ctype): local files. See L{media_release}. @param psz_mrl: the media location. - @return: the newly created media or NULL on error. + @return: the newly created media or None on error. ''' return libvlc_media_new_location(self, str_to_bytes(psz_mrl)) + def media_new_path(self, path): '''Create a media for a certain file path. See L{media_release}. @param path: local filesystem path. - @return: the newly created media or NULL on error. + @return: the newly created media or None on error. ''' return libvlc_media_new_path(self, str_to_bytes(path)) + def media_new_fd(self, fd): '''Create a media for an already open file descriptor. The file descriptor shall be open for reading (or reading and writing). @@ -1550,42 +1754,70 @@ class Instance(_Ctype): descriptor should probably be rewound to the beginning with lseek(). See L{media_release}. @param fd: open file descriptor. - @return: the newly created media or NULL on error. + @return: the newly created media or None on error. @version: LibVLC 1.1.5 and later. ''' return libvlc_media_new_fd(self, fd) + + def media_new_callbacks(self, open_cb, read_cb, seek_cb, close_cb, opaque): + '''Create a media with custom callbacks to read the data from. + @param open_cb: callback to open the custom bitstream input media. + @param read_cb: callback to read data (must not be None). + @param seek_cb: callback to seek, or None if seeking is not supported. + @param close_cb: callback to close the media, or None if unnecessary. + @param opaque: data pointer for the open callback. + @return: the newly created media or None on error @note If open_cb is None, the opaque pointer will be passed to read_cb, seek_cb and close_cb, and the stream size will be treated as unknown. @note The callbacks may be called asynchronously (from another thread). A single stream instance need not be reentrant. However the open_cb needs to be reentrant if the media is used by multiple player instances. @warning The callbacks may be used until all or any player instances that were supplied the media item are stopped. See L{media_release}. + @version: LibVLC 3.0.0 and later. + ''' + return libvlc_media_new_callbacks(self, open_cb, read_cb, seek_cb, close_cb, opaque) + + def media_new_as_node(self, psz_name): '''Create a media as an empty node with a given name. See L{media_release}. @param psz_name: the name of the node. - @return: the new empty media or NULL on error. + @return: the new empty media or None on error. ''' return libvlc_media_new_as_node(self, str_to_bytes(psz_name)) - def media_discoverer_new_from_name(self, psz_name): - '''Discover media service by name. + + def media_discoverer_new(self, psz_name): + '''Create a media discoverer object by name. + After this object is created, you should attach to events in order to be + notified of the discoverer state. + You should also attach to media_list events in order to be notified of new + items discovered. + You need to call L{media_discoverer_start}() in order to start the + discovery. + See L{media_discoverer_media_list} + See L{media_discoverer_event_manager} + See L{media_discoverer_start}. @param psz_name: service name. - @return: media discover object or NULL in case of error. + @return: media discover object or None in case of error. + @version: LibVLC 3.0.0 or later. ''' - return libvlc_media_discoverer_new_from_name(self, str_to_bytes(psz_name)) + return libvlc_media_discoverer_new(self, str_to_bytes(psz_name)) + def media_library_new(self): '''Create an new Media Library object. - @return: a new object or NULL on error. + @return: a new object or None on error. ''' return libvlc_media_library_new(self) + def audio_output_list_get(self): '''Gets the list of available audio output modules. - @return: list of available audio outputs. It must be freed it with In case of error, NULL is returned. + @return: list of available audio outputs. It must be freed with In case of error, None is returned. ''' return libvlc_audio_output_list_get(self) + def audio_output_device_list_get(self, aout): '''Gets a list of audio output devices for a given audio output module, See L{audio_output_device_set}(). - @note: Not all audio outputs support this. In particular, an empty (NULL) + @note: Not all audio outputs support this. In particular, an empty (None) list of devices does B{not} imply that the specified audio output does not work. @note: The list might not be exhaustive. @@ -1593,16 +1825,18 @@ class Instance(_Ctype): some circumstances. By default, it is recommended to not specify any explicit audio device. @param psz_aout: audio output name (as returned by L{audio_output_list_get}()). - @return: A NULL-terminated linked list of potential audio output devices. It must be freed it with L{audio_output_device_list_release}(). + @return: A None-terminated linked list of potential audio output devices. It must be freed with L{audio_output_device_list_release}(). @version: LibVLC 2.1.0 or later. ''' return libvlc_audio_output_device_list_get(self, str_to_bytes(aout)) + def vlm_release(self): '''Release the vlm instance related to the given L{Instance}. ''' return libvlc_vlm_release(self) + def vlm_add_broadcast(self, psz_name, psz_input, psz_output, i_options, ppsz_options, b_enabled, b_loop): '''Add a broadcast, with one input. @param psz_name: the name of the new broadcast. @@ -1616,6 +1850,7 @@ class Instance(_Ctype): ''' return libvlc_vlm_add_broadcast(self, str_to_bytes(psz_name), str_to_bytes(psz_input), str_to_bytes(psz_output), i_options, ppsz_options, b_enabled, b_loop) + def vlm_add_vod(self, psz_name, psz_input, i_options, ppsz_options, b_enabled, psz_mux): '''Add a vod, with one input. @param psz_name: the name of the new vod media. @@ -1628,6 +1863,7 @@ class Instance(_Ctype): ''' return libvlc_vlm_add_vod(self, str_to_bytes(psz_name), str_to_bytes(psz_input), i_options, ppsz_options, b_enabled, str_to_bytes(psz_mux)) + def vlm_del_media(self, psz_name): '''Delete a media (VOD or broadcast). @param psz_name: the media to delete. @@ -1635,6 +1871,7 @@ class Instance(_Ctype): ''' return libvlc_vlm_del_media(self, str_to_bytes(psz_name)) + def vlm_set_enabled(self, psz_name, b_enabled): '''Enable or disable a media (VOD or broadcast). @param psz_name: the media to work on. @@ -1643,6 +1880,7 @@ class Instance(_Ctype): ''' return libvlc_vlm_set_enabled(self, str_to_bytes(psz_name), b_enabled) + def vlm_set_output(self, psz_name, psz_output): '''Set the output for a media. @param psz_name: the media to work on. @@ -1651,6 +1889,7 @@ class Instance(_Ctype): ''' return libvlc_vlm_set_output(self, str_to_bytes(psz_name), str_to_bytes(psz_output)) + def vlm_set_input(self, psz_name, psz_input): '''Set a media's input MRL. This will delete all existing inputs and add the specified one. @@ -1660,6 +1899,7 @@ class Instance(_Ctype): ''' return libvlc_vlm_set_input(self, str_to_bytes(psz_name), str_to_bytes(psz_input)) + def vlm_add_input(self, psz_name, psz_input): '''Add a media's input MRL. This will add the specified one. @param psz_name: the media to work on. @@ -1668,6 +1908,7 @@ class Instance(_Ctype): ''' return libvlc_vlm_add_input(self, str_to_bytes(psz_name), str_to_bytes(psz_input)) + def vlm_set_loop(self, psz_name, b_loop): '''Set a media's loop status. @param psz_name: the media to work on. @@ -1676,6 +1917,7 @@ class Instance(_Ctype): ''' return libvlc_vlm_set_loop(self, str_to_bytes(psz_name), b_loop) + def vlm_set_mux(self, psz_name, psz_mux): '''Set a media's vod muxer. @param psz_name: the media to work on. @@ -1684,6 +1926,7 @@ class Instance(_Ctype): ''' return libvlc_vlm_set_mux(self, str_to_bytes(psz_name), str_to_bytes(psz_mux)) + def vlm_change_media(self, psz_name, psz_input, psz_output, i_options, ppsz_options, b_enabled, b_loop): '''Edit the parameters of a media. This will delete all existing inputs and add the specified one. @@ -1698,6 +1941,7 @@ class Instance(_Ctype): ''' return libvlc_vlm_change_media(self, str_to_bytes(psz_name), str_to_bytes(psz_input), str_to_bytes(psz_output), i_options, ppsz_options, b_enabled, b_loop) + def vlm_play_media(self, psz_name): '''Play the named broadcast. @param psz_name: the name of the broadcast. @@ -1705,6 +1949,7 @@ class Instance(_Ctype): ''' return libvlc_vlm_play_media(self, str_to_bytes(psz_name)) + def vlm_stop_media(self, psz_name): '''Stop the named broadcast. @param psz_name: the name of the broadcast. @@ -1712,6 +1957,7 @@ class Instance(_Ctype): ''' return libvlc_vlm_stop_media(self, str_to_bytes(psz_name)) + def vlm_pause_media(self, psz_name): '''Pause the named broadcast. @param psz_name: the name of the broadcast. @@ -1719,6 +1965,7 @@ class Instance(_Ctype): ''' return libvlc_vlm_pause_media(self, str_to_bytes(psz_name)) + def vlm_seek_media(self, psz_name, f_percentage): '''Seek in the named broadcast. @param psz_name: the name of the broadcast. @@ -1727,6 +1974,7 @@ class Instance(_Ctype): ''' return libvlc_vlm_seek_media(self, str_to_bytes(psz_name), f_percentage) + def vlm_show_media(self, psz_name): '''Return information about the named media as a JSON string representation. @@ -1737,10 +1985,11 @@ class Instance(_Ctype): Currently there are no such functions available for vlm_media_t though. @param psz_name: the name of the media, if the name is an empty string, all media is described. - @return: string with information about named media, or NULL on error. + @return: string with information about named media, or None on error. ''' return libvlc_vlm_show_media(self, str_to_bytes(psz_name)) + def vlm_get_media_instance_position(self, psz_name, i_instance): '''Get vlm_media instance position by name or instance id. @param psz_name: name of vlm media instance. @@ -1749,6 +1998,7 @@ class Instance(_Ctype): ''' return libvlc_vlm_get_media_instance_position(self, str_to_bytes(psz_name), i_instance) + def vlm_get_media_instance_time(self, psz_name, i_instance): '''Get vlm_media instance time by name or instance id. @param psz_name: name of vlm media instance. @@ -1757,6 +2007,7 @@ class Instance(_Ctype): ''' return libvlc_vlm_get_media_instance_time(self, str_to_bytes(psz_name), i_instance) + def vlm_get_media_instance_length(self, psz_name, i_instance): '''Get vlm_media instance length by name or instance id. @param psz_name: name of vlm media instance. @@ -1765,6 +2016,7 @@ class Instance(_Ctype): ''' return libvlc_vlm_get_media_instance_length(self, str_to_bytes(psz_name), i_instance) + def vlm_get_media_instance_rate(self, psz_name, i_instance): '''Get vlm_media instance playback rate by name or instance id. @param psz_name: name of vlm media instance. @@ -1773,6 +2025,7 @@ class Instance(_Ctype): ''' return libvlc_vlm_get_media_instance_rate(self, str_to_bytes(psz_name), i_instance) + def vlm_get_media_instance_title(self, psz_name, i_instance): '''Get vlm_media instance title number by name or instance id. @param psz_name: name of vlm media instance. @@ -1782,6 +2035,7 @@ class Instance(_Ctype): ''' return libvlc_vlm_get_media_instance_title(self, str_to_bytes(psz_name), i_instance) + def vlm_get_media_instance_chapter(self, psz_name, i_instance): '''Get vlm_media instance chapter number by name or instance id. @param psz_name: name of vlm media instance. @@ -1791,6 +2045,7 @@ class Instance(_Ctype): ''' return libvlc_vlm_get_media_instance_chapter(self, str_to_bytes(psz_name), i_instance) + def vlm_get_media_instance_seekable(self, psz_name, i_instance): '''Is libvlc instance seekable ? @param psz_name: name of vlm media instance. @@ -1800,6 +2055,7 @@ class Instance(_Ctype): ''' return libvlc_vlm_get_media_instance_seekable(self, str_to_bytes(psz_name), i_instance) + @memoize_parameterless def vlm_get_event_manager(self): '''Get libvlc_event_manager from a vlm media. The p_event_manager is immutable, so you don't have to hold the lock. @@ -1809,11 +2065,11 @@ class Instance(_Ctype): class Media(_Ctype): '''Create a new Media instance. - + Usage: Media(MRL, *options) See vlc.Instance.media_new documentation for details. - + ''' def __new__(cls, *args): @@ -1833,13 +2089,10 @@ class Media(_Ctype): def add_options(self, *options): """Add a list of options to the media. - Options must be written without the double-dash, e.g.: - - C{m.add_options('sub-filter=marq@test{marquee=Hello}', 'video-filter=invert')} - - Alternatively, the options can directly be passed in the Instance.media_new method: - - C{m = instance.media_new('foo.avi', 'sub-filter=marq@test{marquee=Hello}', 'video-filter=invert')} + Options must be written without the double-dash. Warning: most + audio and video options, such as text renderer, have no + effects on an individual media. These options must be set at + the vlc.Instance or vlc.MediaPlayer instanciation. @param options: optional media option=value strings """ @@ -1855,11 +2108,12 @@ class Media(_Ctype): @version: LibVLC 2.1.0 and later. """ mediaTrack_pp = ctypes.POINTER(MediaTrack)() - n = libvlc_media_tracks_get(self, byref(mediaTrack_pp)) - info = cast(ctypes.mediaTrack_pp, ctypes.POINTER(ctypes.POINTER(MediaTrack) * n)) + n = libvlc_media_tracks_get(self, ctypes.byref(mediaTrack_pp)) + info = ctypes.cast(ctypes.mediaTrack_pp, ctypes.POINTER(ctypes.POINTER(MediaTrack) * n)) return info + def add_option(self, psz_options): '''Add an option to the media. This option will be used to determine how the media_player will @@ -1876,6 +2130,7 @@ class Media(_Ctype): ''' return libvlc_media_add_option(self, str_to_bytes(psz_options)) + def add_option_flag(self, psz_options, i_flags): '''Add an option to the media with configurable flags. This option will be used to determine how the media_player will @@ -1891,6 +2146,7 @@ class Media(_Ctype): ''' return libvlc_media_add_option_flag(self, str_to_bytes(psz_options), i_flags) + def retain(self): '''Retain a reference to a media descriptor object (libvlc_media_t). Use L{release}() to decrement the reference count of a @@ -1898,6 +2154,7 @@ class Media(_Ctype): ''' return libvlc_media_retain(self) + def release(self): '''Decrement the reference count of a media descriptor object. If the reference count is 0, then L{release}() will release the @@ -1907,20 +2164,23 @@ class Media(_Ctype): ''' return libvlc_media_release(self) + def get_mrl(self): '''Get the media resource locator (mrl) from a media descriptor object. @return: string with mrl of media descriptor object. ''' return libvlc_media_get_mrl(self) + def duplicate(self): '''Duplicate a media descriptor object. ''' return libvlc_media_duplicate(self) + def get_meta(self, e_meta): '''Read the meta of the media. - If the media has not yet been parsed this will return NULL. + If the media has not yet been parsed this will return None. This methods automatically calls L{parse_async}(), so after calling it you may receive a libvlc_MediaMetaChanged event. If you prefer a synchronous version ensure that you call L{parse}() before get_meta(). @@ -1932,6 +2192,7 @@ class Media(_Ctype): ''' return libvlc_media_get_meta(self, e_meta) + def set_meta(self, e_meta, psz_value): '''Set the meta of the media (this function will not save the meta, call L{save_meta} in order to save the meta). @@ -1940,12 +2201,14 @@ class Media(_Ctype): ''' return libvlc_media_set_meta(self, e_meta, str_to_bytes(psz_value)) + def save_meta(self): '''Save the meta previously set. @return: true if the write operation was successful. ''' return libvlc_media_save_meta(self) + def get_state(self): '''Get current state of media descriptor object. Possible media states are defined in libvlc_structures.c ( libvlc_NothingSpecial=0, @@ -1957,6 +2220,7 @@ class Media(_Ctype): ''' return libvlc_media_get_state(self) + def get_stats(self, p_stats): '''Get the current statistics about the media. @param p_stats:: structure that contain the statistics about the media (this structure must be allocated by the caller). @@ -1964,14 +2228,16 @@ class Media(_Ctype): ''' return libvlc_media_get_stats(self, p_stats) + def subitems(self): '''Get subitems of media descriptor object. This will increment the reference count of supplied media descriptor object. Use L{list_release}() to decrement the reference counting. - @return: list of media descriptor subitems or NULL. + @return: list of media descriptor subitems or None. ''' return libvlc_media_subitems(self) + @memoize_parameterless def event_manager(self): '''Get event manager from media descriptor object. NOTE: this function doesn't increment reference counting. @@ -1979,15 +2245,17 @@ class Media(_Ctype): ''' return libvlc_media_event_manager(self) + def get_duration(self): '''Get duration (in ms) of media descriptor object item. @return: duration of media item or -1 on error. ''' return libvlc_media_get_duration(self) + def parse(self): '''Parse a media. - This fetches (local) meta data and tracks information. + This fetches (local) art, meta data and tracks information. The method is synchronous. See L{parse_async} See L{get_meta} @@ -1995,9 +2263,10 @@ class Media(_Ctype): ''' return libvlc_media_parse(self) + def parse_async(self): '''Parse a media. - This fetches (local) meta data and tracks information. + This fetches (local) art, meta data and tracks information. The method is the asynchronous of L{parse}(). To track when this is over you can listen to libvlc_MediaParsedChanged event. However if the media was already parsed you will not receive this @@ -2009,6 +2278,28 @@ class Media(_Ctype): ''' return libvlc_media_parse_async(self) + + def parse_with_options(self, parse_flag): + '''Parse the media asynchronously with options. + This fetches (local or network) art, meta data and/or tracks information. + This method is the extended version of L{parse_async}(). + To track when this is over you can listen to libvlc_MediaParsedChanged + event. However if this functions returns an error, you will not receive this + event. + It uses a flag to specify parse options (see libvlc_media_parse_flag_t). All + these flags can be combined. By default, media is parsed if it's a local + file. + See libvlc_MediaParsedChanged + See L{get_meta} + See L{tracks_get} + See libvlc_media_parse_flag_t. + @param parse_flag: parse options: + @return: -1 in case of error, 0 otherwise. + @version: LibVLC 3.0.0 or later. + ''' + return libvlc_media_parse_with_options(self, parse_flag) + + def is_parsed(self): '''Get Parsed status for media descriptor object. See libvlc_MediaParsedChanged. @@ -2016,6 +2307,7 @@ class Media(_Ctype): ''' return libvlc_media_is_parsed(self) + def set_user_data(self, p_new_user_data): '''Sets media descriptor's user_data. user_data is specialized data accessed by the host application, VLC.framework uses it as a pointer to @@ -2024,6 +2316,7 @@ class Media(_Ctype): ''' return libvlc_media_set_user_data(self, p_new_user_data) + def get_user_data(self): '''Get media descriptor's user_data. user_data is specialized data accessed by the host application, VLC.framework uses it as a pointer to @@ -2031,9 +2324,18 @@ class Media(_Ctype): ''' return libvlc_media_get_user_data(self) + + def get_type(self): + '''Get the media type of the media descriptor object. + @return: media type. + @version: LibVLC 3.0.0 and later. See libvlc_media_type_t. + ''' + return libvlc_media_get_type(self) + + def player_new_from_media(self): '''Create a Media Player object from a Media. - @return: a new media player object, or NULL on error. + @return: a new media player object, or None on error. ''' return libvlc_media_player_new_from_media(self) @@ -2045,30 +2347,54 @@ class MediaDiscoverer(_Ctype): '''(INTERNAL) ctypes wrapper constructor. ''' return _Constructor(cls, ptr) + + def start(self): + '''Start media discovery. + To stop it, call L{stop}() or + L{release}() directly. + See L{stop}. + @return: -1 in case of error, 0 otherwise. + @version: LibVLC 3.0.0 or later. + ''' + return libvlc_media_discoverer_start(self) + + + def stop(self): + '''Stop media discovery. + See L{start}. + @version: LibVLC 3.0.0 or later. + ''' + return libvlc_media_discoverer_stop(self) + + def release(self): '''Release media discover object. If the reference count reaches 0, then the object will be released. ''' return libvlc_media_discoverer_release(self) + def localized_name(self): '''Get media service discover object its localized name. @return: localized name. ''' return libvlc_media_discoverer_localized_name(self) + def media_list(self): '''Get media service discover media list. @return: list of media items. ''' return libvlc_media_discoverer_media_list(self) + @memoize_parameterless def event_manager(self): '''Get event manager from media service discover object. @return: event manager object. ''' return libvlc_media_discoverer_event_manager(self) + def is_running(self): '''Query if media service discover object is running. @return: true if running, false if not \libvlc_return_bool. @@ -2083,6 +2409,7 @@ class MediaLibrary(_Ctype): '''(INTERNAL) ctypes wrapper constructor. ''' return _Constructor(cls, ptr) + def release(self): '''Release media library object. This functions decrements the reference count of the media library object. If it reaches 0, @@ -2090,6 +2417,7 @@ class MediaLibrary(_Ctype): ''' return libvlc_media_library_release(self) + def retain(self): '''Retain a reference to a media library object. This function will increment the reference counting for this object. Use @@ -2097,12 +2425,14 @@ class MediaLibrary(_Ctype): ''' return libvlc_media_library_retain(self) + def load(self): '''Load media library. @return: 0 on success, -1 on error. ''' return libvlc_media_library_load(self) + def media_list(self): '''Get media library subitems. @return: media list subitems. @@ -2111,11 +2441,11 @@ class MediaLibrary(_Ctype): class MediaList(_Ctype): '''Create a new MediaList instance. - + Usage: MediaList(list_of_MRLs) See vlc.Instance.media_list_new documentation for details. - + ''' def __new__(cls, *args): @@ -2131,10 +2461,10 @@ class MediaList(_Ctype): def get_instance(self): return getattr(self, '_instance', None) - + def add_media(self, mrl): """Add media instance to media list. - + The L{lock} should be held upon entering this function. @param mrl: a media instance or a MRL. @return: 0 on success, -1 if the media list is read-only. @@ -2144,16 +2474,19 @@ class MediaList(_Ctype): return libvlc_media_list_add_media(self, mrl) + def release(self): '''Release media list created with L{new}(). ''' return libvlc_media_list_release(self) + def retain(self): '''Retain reference to a media list. ''' return libvlc_media_list_retain(self) + def set_media(self, p_md): '''Associate media instance with this media list instance. If another media instance was present it will be released. @@ -2162,6 +2495,7 @@ class MediaList(_Ctype): ''' return libvlc_media_list_set_media(self, p_md) + def media(self): '''Get media instance from this media list instance. This action will increase the refcount on the media instance. @@ -2170,6 +2504,7 @@ class MediaList(_Ctype): ''' return libvlc_media_list_media(self) + def insert_media(self, p_md, i_pos): '''Insert media instance in media list on a position The L{lock} should be held upon entering this function. @@ -2179,6 +2514,7 @@ class MediaList(_Ctype): ''' return libvlc_media_list_insert_media(self, p_md, i_pos) + def remove_index(self, i_pos): '''Remove media instance from media list on a position The L{lock} should be held upon entering this function. @@ -2187,6 +2523,7 @@ class MediaList(_Ctype): ''' return libvlc_media_list_remove_index(self, i_pos) + def count(self): '''Get count on media list items The L{lock} should be held upon entering this function. @@ -2197,11 +2534,12 @@ class MediaList(_Ctype): def __len__(self): return libvlc_media_list_count(self) + def item_at_index(self, i_pos): '''List media instance in media list at a position The L{lock} should be held upon entering this function. @param i_pos: position in array where to insert. - @return: media instance at position i_pos, or NULL if not found. In case of success, L{media_retain}() is called to increase the refcount on the media. + @return: media instance at position i_pos, or None if not found. In case of success, L{media_retain}() is called to increase the refcount on the media. ''' return libvlc_media_list_item_at_index(self, i_pos) @@ -2212,6 +2550,7 @@ class MediaList(_Ctype): for i in range(len(self)): yield self[i] + def index_of_item(self, p_md): '''Find index position of List media instance in media list. Warning: the function will return the first matched position. @@ -2221,23 +2560,27 @@ class MediaList(_Ctype): ''' return libvlc_media_list_index_of_item(self, p_md) + def is_readonly(self): '''This indicates if this media list is read-only from a user point of view. @return: 1 on readonly, 0 on readwrite \libvlc_return_bool. ''' return libvlc_media_list_is_readonly(self) + def lock(self): '''Get lock on media list items. ''' return libvlc_media_list_lock(self) + def unlock(self): '''Release lock on media list items The L{lock} should be held upon entering this function. ''' return libvlc_media_list_unlock(self) + @memoize_parameterless def event_manager(self): '''Get libvlc_event_manager from this media list instance. The p_event_manager is immutable, so you don't have to hold the lock. @@ -2251,7 +2594,7 @@ class MediaListPlayer(_Ctype): It may take as parameter either: - a vlc.Instance - nothing - + ''' def __new__(cls, arg=None): @@ -2272,6 +2615,7 @@ class MediaListPlayer(_Ctype): return self._instance #PYCHOK expected + def release(self): '''Release a media_list_player after use Decrement the reference count of a media player object. If the @@ -2281,52 +2625,68 @@ class MediaListPlayer(_Ctype): ''' return libvlc_media_list_player_release(self) + def retain(self): '''Retain a reference to a media player list object. Use L{release}() to decrement reference count. ''' return libvlc_media_list_player_retain(self) + @memoize_parameterless def event_manager(self): '''Return the event manager of this media_list_player. @return: the event manager. ''' return libvlc_media_list_player_event_manager(self) + def set_media_player(self, p_mi): '''Replace media player in media_list_player with this instance. @param p_mi: media player instance. ''' return libvlc_media_list_player_set_media_player(self, p_mi) + + def get_media_player(self): + '''Get media player of the media_list_player instance. + @return: media player instance @note the caller is responsible for releasing the returned instance. + ''' + return libvlc_media_list_player_get_media_player(self) + + def set_media_list(self, p_mlist): '''Set the media list associated with the player. @param p_mlist: list of media. ''' return libvlc_media_list_player_set_media_list(self, p_mlist) + def play(self): '''Play media list. ''' return libvlc_media_list_player_play(self) + def pause(self): '''Toggle pause (or resume) media list. ''' return libvlc_media_list_player_pause(self) + def is_playing(self): '''Is media list playing? @return: true for playing and false for not playing \libvlc_return_bool. ''' return libvlc_media_list_player_is_playing(self) + def get_state(self): '''Get current libvlc_state of media list player. @return: libvlc_state_t for media list player. ''' return libvlc_media_list_player_get_state(self) + def play_item_at_index(self, i_index): '''Play media list item at position index. @param i_index: index in media list to play. @@ -2341,6 +2701,7 @@ class MediaListPlayer(_Ctype): for i in range(len(self)): yield self[i] + def play_item(self, p_md): '''Play the given media item. @param p_md: the media instance. @@ -2348,23 +2709,27 @@ class MediaListPlayer(_Ctype): ''' return libvlc_media_list_player_play_item(self, p_md) + def stop(self): '''Stop playing media list. ''' return libvlc_media_list_player_stop(self) + def next(self): '''Play next item from media list. @return: 0 upon success -1 if there is no next item. ''' return libvlc_media_list_player_next(self) + def previous(self): '''Play previous item from media list. @return: 0 upon success -1 if there is no previous item. ''' return libvlc_media_list_player_previous(self) + def set_playback_mode(self, e_mode): '''Sets the playback mode for the playlist. @param e_mode: playback mode specification. @@ -2377,13 +2742,13 @@ class MediaPlayer(_Ctype): It may take as parameter either: - a string (media URI), options... In this case, a vlc.Instance will be created. - a vlc.Instance, a string (media URI), options... - + ''' def __new__(cls, *args): if len(args) == 1 and isinstance(args[0], _Ints): return _Constructor(cls, args[0]) - + if args and isinstance(args[0], Instance): instance = args[0] args = args[1:] @@ -2403,6 +2768,10 @@ class MediaPlayer(_Ctype): def set_mrl(self, mrl, *options): """Set the MRL to play. + Warning: most audio and video options, such as text renderer, + have no effects on an individual media. These options must be + set at the vlc.Instance or vlc.MediaPlayer instanciation. + @param mrl: The MRL @param options: optional media option=value strings @return: the Media object @@ -2438,6 +2807,27 @@ class MediaPlayer(_Ctype): """ return track_description_list(libvlc_audio_get_track_description(self)) + def get_full_title_descriptions(self): + '''Get the full description of available titles. + @return: the titles list + @version: LibVLC 3.0.0 and later. + ''' + titleDescription_pp = ctypes.POINTER(TitleDescription)() + n = libvlc_media_player_get_full_title_descriptions(self, ctypes.byref(titleDescription_pp)) + info = ctypes.cast(ctypes.titleDescription_pp, ctypes.POINTER(ctypes.POINTER(TitleDescription) * n)) + return info + + def get_full_chapter_descriptions(self, i_chapters_of_title): + '''Get the full description of available chapters. + @param index: of the title to query for chapters. + @return: the chapter list + @version: LibVLC 3.0.0 and later. + ''' + chapterDescription_pp = ctypes.POINTER(ChapterDescription)() + n = libvlc_media_player_get_full_chapter_descriptions(self, ctypes.byref(chapterDescription_pp)) + info = ctypes.cast(ctypes.chapterDescription_pp, ctypes.POINTER(ctypes.POINTER(ChapterDescription) * n)) + return info + def video_get_size(self, num=0): """Get the video size in pixels as 2-tuple (width, height). @@ -2455,13 +2845,13 @@ class MediaPlayer(_Ctype): Specify where the media player should render its video output. If LibVLC was built without Win32/Win64 API output support, then this has no effects. - + @param drawable: windows handle of the drawable. """ if not isinstance(drawable, ctypes.c_void_p): drawable = ctypes.c_void_p(int(drawable)) libvlc_media_player_set_hwnd(self, drawable) - + def video_get_width(self, num=0): """Get the width of a video in pixels. @@ -2501,6 +2891,7 @@ class MediaPlayer(_Ctype): raise VLCException('invalid video number (%s)' % (num,)) + def release(self): '''Release a media_player after use Decrement the reference count of a media player object. If the @@ -2510,12 +2901,14 @@ class MediaPlayer(_Ctype): ''' return libvlc_media_player_release(self) + def retain(self): '''Retain a reference to a media player object. Use L{release}() to decrement reference count. ''' return libvlc_media_player_retain(self) + def set_media(self, p_md): '''Set the media that will be used by the media_player. If any, previous md will be released. @@ -2523,30 +2916,35 @@ class MediaPlayer(_Ctype): ''' return libvlc_media_player_set_media(self, p_md) + def get_media(self): '''Get the media used by the media_player. - @return: the media associated with p_mi, or NULL if no media is associated. + @return: the media associated with p_mi, or None if no media is associated. ''' return libvlc_media_player_get_media(self) + @memoize_parameterless def event_manager(self): '''Get the Event Manager from which the media player send event. @return: the event manager associated with p_mi. ''' return libvlc_media_player_event_manager(self) + def is_playing(self): '''is_playing. @return: 1 if the media player is playing, 0 otherwise \libvlc_return_bool. ''' return libvlc_media_player_is_playing(self) + def play(self): '''Play. @return: 0 if playback started (and was already started), or -1 on error. ''' return libvlc_media_player_play(self) + def set_pause(self, do_pause): '''Pause or resume (no effect if there is no media). @param do_pause: play/resume if zero, pause if non-zero. @@ -2554,29 +2952,33 @@ class MediaPlayer(_Ctype): ''' return libvlc_media_player_set_pause(self, do_pause) + def pause(self): '''Toggle pause (no effect if there is no media). ''' return libvlc_media_player_pause(self) + def stop(self): '''Stop (no effect if there is no media). ''' return libvlc_media_player_stop(self) + def video_set_callbacks(self, lock, unlock, display, opaque): '''Set callbacks and private data to render decoded video to a custom area in memory. Use L{video_set_format}() or L{video_set_format_callbacks}() to configure the decoded format. - @param lock: callback to lock video memory (must not be NULL). - @param unlock: callback to unlock video memory (or NULL if not needed). - @param display: callback to display video (or NULL if not needed). + @param lock: callback to lock video memory (must not be None). + @param unlock: callback to unlock video memory (or None if not needed). + @param display: callback to display video (or None if not needed). @param opaque: private pointer for the three callbacks (as first parameter). @version: LibVLC 1.1.1 or later. ''' return libvlc_video_set_callbacks(self, lock, unlock, display, opaque) + def video_set_format(self, chroma, width, height, pitch): '''Set decoded video chroma and dimensions. This only works in combination with L{video_set_callbacks}(), @@ -2590,21 +2992,23 @@ class MediaPlayer(_Ctype): ''' return libvlc_video_set_format(self, str_to_bytes(chroma), width, height, pitch) + def video_set_format_callbacks(self, setup, cleanup): '''Set decoded video chroma and dimensions. This only works in combination with L{video_set_callbacks}(). - @param setup: callback to select the video format (cannot be NULL). - @param cleanup: callback to release any allocated resources (or NULL). + @param setup: callback to select the video format (cannot be None). + @param cleanup: callback to release any allocated resources (or None). @version: LibVLC 2.0.0 or later. ''' return libvlc_video_set_format_callbacks(self, setup, cleanup) + def set_nsobject(self, drawable): '''Set the NSView handler where the media player should render its video output. Use the vout called "macosx". The drawable is an NSObject that follow the VLCOpenGLVideoViewEmbedding protocol: - @begincode + @code.m \@protocol VLCOpenGLVideoViewEmbedding - (void)addVoutSubview:(NSView *)view; - (void)removeVoutSubview:(NSView *)view; @@ -2613,50 +3017,62 @@ class MediaPlayer(_Ctype): Or it can be an NSView object. If you want to use it along with Qt4 see the QMacCocoaViewContainer. Then the following code should work: - @begincode - + @code.mm + NSView *video = [[NSView alloc] init]; QMacCocoaViewContainer *container = new QMacCocoaViewContainer(video, parent); L{set_nsobject}(mp, video); [video release]; - + @endcode You can find a live example in VLCVideoView in VLCKit.framework. @param drawable: the drawable that is either an NSView or an object following the VLCOpenGLVideoViewEmbedding protocol. ''' return libvlc_media_player_set_nsobject(self, drawable) + def get_nsobject(self): '''Get the NSView handler previously set with L{set_nsobject}(). @return: the NSView handler or 0 if none where set. ''' return libvlc_media_player_get_nsobject(self) + def set_agl(self, drawable): - '''Set the agl handler where the media player should render its video output. - @param drawable: the agl handler. + '''\deprecated Use L{set_nsobject} instead. ''' return libvlc_media_player_set_agl(self, drawable) + def get_agl(self): - '''Get the agl handler previously set with L{set_agl}(). - @return: the agl handler or 0 if none where set. + '''\deprecated Use L{get_nsobject} instead. ''' return libvlc_media_player_get_agl(self) + def set_xwindow(self, drawable): '''Set an X Window System drawable where the media player should render its - video output. If LibVLC was built without X11 output support, then this has - no effects. - The specified identifier must correspond to an existing Input/Output class - X11 window. Pixmaps are B{not} supported. The caller shall ensure that - the X11 server is the same as the one the VLC instance has been configured - with. This function must be called before video playback is started; - otherwise it will only take effect after playback stop and restart. - @param drawable: the ID of the X window. + video output. The call takes effect when the playback starts. If it is + already started, it might need to be stopped before changes apply. + If LibVLC was built without X11 output support, then this function has no + effects. + By default, LibVLC will capture input events on the video rendering area. + Use L{video_set_mouse_input}() and L{video_set_key_input}() to + disable that and deliver events to the parent window / to the application + instead. By design, the X11 protocol delivers input events to only one + recipient. + @warning + The application must call the XInitThreads() function from Xlib before + L{new}(), and before any call to XOpenDisplay() directly or via any + other library. Failure to call XInitThreads() will seriously impede LibVLC + performance. Calling XOpenDisplay() before XInitThreads() will eventually + crash the process. That is a limitation of Xlib. + @param drawable: X11 window ID @note The specified identifier must correspond to an existing Input/Output class X11 window. Pixmaps are B{not} currently supported. The default X11 server is assumed, i.e. that specified in the DISPLAY environment variable. @warning LibVLC can deal with invalid X11 handle errors, however some display drivers (EGL, GLX, VA and/or VDPAU) can unfortunately not. Thus the window handle must remain valid until playback is stopped, otherwise the process may abort or crash. + @bug No more than one window handle per media player instance can be specified. If the media has multiple simultaneously active video tracks, extra tracks will be rendered into external windows beyond the control of the application. ''' return libvlc_media_player_set_xwindow(self, drawable) + def get_xwindow(self): '''Get the X Window System window identifier previously set with L{set_xwindow}(). Note that this will return the identifier @@ -2666,46 +3082,61 @@ class MediaPlayer(_Ctype): ''' return libvlc_media_player_get_xwindow(self) + def get_hwnd(self): '''Get the Windows API window handle (HWND) previously set with L{set_hwnd}(). The handle will be returned even if LibVLC is not currently outputting any video to it. - @return: a window handle or NULL if there are none. + @return: a window handle or None if there are none. ''' return libvlc_media_player_get_hwnd(self) + + def set_android_context(self, p_jvm, p_awindow_handler): + '''Set the android context. + @param p_jvm: the Java VM of the android process. + @param awindow_handler: org.videolan.libvlc.IAWindowNativeHandler jobject implemented by the org.videolan.libvlc.MediaPlayer class from the libvlc-android project. + @version: LibVLC 3.0.0 and later. + ''' + return libvlc_media_player_set_android_context(self, p_jvm, p_awindow_handler) + + def audio_set_callbacks(self, play, pause, resume, flush, drain, opaque): '''Set callbacks and private data for decoded audio. Use L{audio_set_format}() or L{audio_set_format_callbacks}() to configure the decoded audio format. - @param play: callback to play audio samples (must not be NULL). - @param pause: callback to pause playback (or NULL to ignore). - @param resume: callback to resume playback (or NULL to ignore). - @param flush: callback to flush audio buffers (or NULL to ignore). - @param drain: callback to drain audio buffers (or NULL to ignore). + @param play: callback to play audio samples (must not be None). + @param pause: callback to pause playback (or None to ignore). + @param resume: callback to resume playback (or None to ignore). + @param flush: callback to flush audio buffers (or None to ignore). + @param drain: callback to drain audio buffers (or None to ignore). @param opaque: private pointer for the audio callbacks (as first parameter). @version: LibVLC 2.0.0 or later. ''' return libvlc_audio_set_callbacks(self, play, pause, resume, flush, drain, opaque) + def audio_set_volume_callback(self, set_volume): - '''Set callbacks and private data for decoded audio. + '''Set callbacks and private data for decoded audio. This only works in + combination with L{audio_set_callbacks}(). Use L{audio_set_format}() or L{audio_set_format_callbacks}() to configure the decoded audio format. - @param set_volume: callback to apply audio volume, or NULL to apply volume in software. + @param set_volume: callback to apply audio volume, or None to apply volume in software. @version: LibVLC 2.0.0 or later. ''' return libvlc_audio_set_volume_callback(self, set_volume) + def audio_set_format_callbacks(self, setup, cleanup): '''Set decoded audio format. This only works in combination with L{audio_set_callbacks}(). - @param setup: callback to select the audio format (cannot be NULL). - @param cleanup: callback to release any allocated resources (or NULL). + @param setup: callback to select the audio format (cannot be None). + @param cleanup: callback to release any allocated resources (or None). @version: LibVLC 2.0.0 or later. ''' return libvlc_audio_set_format_callbacks(self, setup, cleanup) + def audio_set_format(self, format, rate, channels): '''Set decoded audio format. This only works in combination with L{audio_set_callbacks}(), @@ -2717,18 +3148,21 @@ class MediaPlayer(_Ctype): ''' return libvlc_audio_set_format(self, str_to_bytes(format), rate, channels) + def get_length(self): '''Get the current movie length (in ms). @return: the movie length (in ms), or -1 if there is no media. ''' return libvlc_media_player_get_length(self) + def get_time(self): '''Get the current movie time (in ms). @return: the movie time (in ms), or -1 if there is no media. ''' return libvlc_media_player_get_time(self) + def set_time(self, i_time): '''Set the movie time (in ms). This has no effect if no media is being played. Not all formats and protocols support this. @@ -2736,12 +3170,14 @@ class MediaPlayer(_Ctype): ''' return libvlc_media_player_set_time(self, i_time) + def get_position(self): '''Get movie position as percentage between 0.0 and 1.0. @return: movie position, or -1. in case of error. ''' return libvlc_media_player_get_position(self) + def set_position(self, f_pos): '''Set movie position as percentage between 0.0 and 1.0. This has no effect if playback is not enabled. @@ -2750,30 +3186,35 @@ class MediaPlayer(_Ctype): ''' return libvlc_media_player_set_position(self, f_pos) + def set_chapter(self, i_chapter): '''Set movie chapter (if applicable). @param i_chapter: chapter number to play. ''' return libvlc_media_player_set_chapter(self, i_chapter) + def get_chapter(self): '''Get movie chapter. @return: chapter number currently playing, or -1 if there is no media. ''' return libvlc_media_player_get_chapter(self) + def get_chapter_count(self): '''Get movie chapter count. @return: number of chapters in movie, or -1. ''' return libvlc_media_player_get_chapter_count(self) + def will_play(self): '''Is the player able to play. @return: boolean \libvlc_return_bool. ''' return libvlc_media_player_will_play(self) + def get_chapter_count_for_title(self, i_title): '''Get title chapter count. @param i_title: title. @@ -2781,34 +3222,40 @@ class MediaPlayer(_Ctype): ''' return libvlc_media_player_get_chapter_count_for_title(self, i_title) + def set_title(self, i_title): '''Set movie title. @param i_title: title number to play. ''' return libvlc_media_player_set_title(self, i_title) + def get_title(self): '''Get movie title. @return: title number currently playing, or -1. ''' return libvlc_media_player_get_title(self) + def get_title_count(self): '''Get movie title count. @return: title number count, or -1. ''' return libvlc_media_player_get_title_count(self) + def previous_chapter(self): '''Set previous chapter (if applicable). ''' return libvlc_media_player_previous_chapter(self) + def next_chapter(self): '''Set next chapter (if applicable). ''' return libvlc_media_player_next_chapter(self) + def get_rate(self): '''Get the requested movie play rate. @warning: Depending on the underlying media, the requested rate may be @@ -2817,6 +3264,7 @@ class MediaPlayer(_Ctype): ''' return libvlc_media_player_get_rate(self) + def set_rate(self, rate): '''Set movie play rate. @param rate: movie play rate to set. @@ -2824,36 +3272,42 @@ class MediaPlayer(_Ctype): ''' return libvlc_media_player_set_rate(self, rate) + def get_state(self): '''Get current movie state. @return: the current state of the media player (playing, paused, ...) See libvlc_state_t. ''' return libvlc_media_player_get_state(self) + def get_fps(self): '''Get movie fps rate. @return: frames per second (fps) for this playing movie, or 0 if unspecified. ''' return libvlc_media_player_get_fps(self) + def has_vout(self): '''How many video outputs does this media player have? @return: the number of video outputs. ''' return libvlc_media_player_has_vout(self) + def is_seekable(self): '''Is this media player seekable? @return: true if the media player can seek \libvlc_return_bool. ''' return libvlc_media_player_is_seekable(self) + def can_pause(self): '''Can this media player be paused? @return: true if the media player can pause \libvlc_return_bool. ''' return libvlc_media_player_can_pause(self) + def program_scrambled(self): '''Check if the current program is scrambled. @return: true if the current program is scrambled \libvlc_return_bool. @@ -2861,11 +3315,13 @@ class MediaPlayer(_Ctype): ''' return libvlc_media_player_program_scrambled(self) + def next_frame(self): '''Display the next frame (if supported). ''' return libvlc_media_player_next_frame(self) + def navigate(self, navigate): '''Navigate through DVD Menu. @param navigate: the Navigation mode. @@ -2873,6 +3329,7 @@ class MediaPlayer(_Ctype): ''' return libvlc_media_player_navigate(self, navigate) + def set_video_title_display(self, position, timeout): '''Set if, and how, the video title will be shown when media is played. @param position: position at which to display the title, or libvlc_position_disable to prevent the title from being displayed. @@ -2881,6 +3338,7 @@ class MediaPlayer(_Ctype): ''' return libvlc_media_player_set_video_title_display(self, position, timeout) + def toggle_fullscreen(self): '''Toggle fullscreen status on non-embedded video outputs. @warning: The same limitations applies to this function @@ -2888,6 +3346,7 @@ class MediaPlayer(_Ctype): ''' return libvlc_toggle_fullscreen(self) + def set_fullscreen(self, b_fullscreen): '''Enable or disable fullscreen. @warning: With most window managers, only a top-level windows can be in @@ -2900,12 +3359,14 @@ class MediaPlayer(_Ctype): ''' return libvlc_set_fullscreen(self, b_fullscreen) + def get_fullscreen(self): '''Get current fullscreen status. @return: the fullscreen status (boolean) \libvlc_return_bool. ''' return libvlc_get_fullscreen(self) + def video_set_key_input(self, on): '''Enable or disable key press events handling, according to the LibVLC hotkeys configuration. By default and for historical reasons, keyboard events are @@ -2919,6 +3380,7 @@ class MediaPlayer(_Ctype): ''' return libvlc_video_set_key_input(self, on) + def video_set_mouse_input(self, on): '''Enable or disable mouse click events handling. By default, those events are handled. This is needed for DVD menus to work, as well as a few video @@ -2929,6 +3391,7 @@ class MediaPlayer(_Ctype): ''' return libvlc_video_set_mouse_input(self, on) + def video_get_scale(self): '''Get the current video scaling factor. See also L{video_set_scale}(). @@ -2936,6 +3399,7 @@ class MediaPlayer(_Ctype): ''' return libvlc_video_get_scale(self) + def video_set_scale(self, f_factor): '''Set the video scaling factor. That is the ratio of the number of pixels on screen to the number of pixels in the original decoded video in each @@ -2946,30 +3410,35 @@ class MediaPlayer(_Ctype): ''' return libvlc_video_set_scale(self, f_factor) + def video_get_aspect_ratio(self): '''Get current video aspect ratio. - @return: the video aspect ratio or NULL if unspecified (the result must be released with free() or L{free}()). + @return: the video aspect ratio or None if unspecified (the result must be released with free() or L{free}()). ''' return libvlc_video_get_aspect_ratio(self) + def video_set_aspect_ratio(self, psz_aspect): '''Set new video aspect ratio. - @param psz_aspect: new video aspect-ratio or NULL to reset to default @note Invalid aspect ratios are ignored. + @param psz_aspect: new video aspect-ratio or None to reset to default @note Invalid aspect ratios are ignored. ''' return libvlc_video_set_aspect_ratio(self, str_to_bytes(psz_aspect)) + def video_get_spu(self): '''Get current video subtitle. @return: the video subtitle selected, or -1 if none. ''' return libvlc_video_get_spu(self) + def video_get_spu_count(self): '''Get the number of available video subtitles. @return: the number of available video subtitles. ''' return libvlc_video_get_spu_count(self) + def video_set_spu(self, i_spu): '''Set new video subtitle. @param i_spu: video subtitle track to select (i_id from track description). @@ -2977,6 +3446,7 @@ class MediaPlayer(_Ctype): ''' return libvlc_video_set_spu(self, i_spu) + def video_set_subtitle_file(self, psz_subtitle): '''Set new video subtitle file. @param psz_subtitle: new video subtitle file. @@ -2984,6 +3454,7 @@ class MediaPlayer(_Ctype): ''' return libvlc_video_set_subtitle_file(self, str_to_bytes(psz_subtitle)) + def video_get_spu_delay(self): '''Get the current subtitle delay. Positive values means subtitles are being displayed later, negative values earlier. @@ -2992,6 +3463,7 @@ class MediaPlayer(_Ctype): ''' return libvlc_video_get_spu_delay(self) + def video_set_spu_delay(self, i_delay): '''Set the subtitle delay. This affects the timing of when the subtitle will be displayed. Positive values result in subtitles being displayed later, @@ -3003,47 +3475,55 @@ class MediaPlayer(_Ctype): ''' return libvlc_video_set_spu_delay(self, i_delay) + def video_get_crop_geometry(self): '''Get current crop filter geometry. - @return: the crop filter geometry or NULL if unset. + @return: the crop filter geometry or None if unset. ''' return libvlc_video_get_crop_geometry(self) + def video_set_crop_geometry(self, psz_geometry): '''Set new crop filter geometry. - @param psz_geometry: new crop filter geometry (NULL to unset). + @param psz_geometry: new crop filter geometry (None to unset). ''' return libvlc_video_set_crop_geometry(self, str_to_bytes(psz_geometry)) + def video_get_teletext(self): '''Get current teletext page requested. @return: the current teletext page requested. ''' return libvlc_video_get_teletext(self) + def video_set_teletext(self, i_page): '''Set new teletext page to retrieve. @param i_page: teletex page number requested. ''' return libvlc_video_set_teletext(self, i_page) + def toggle_teletext(self): '''Toggle teletext transparent status on video output. ''' return libvlc_toggle_teletext(self) + def video_get_track_count(self): '''Get number of available video tracks. @return: the number of available video tracks (int). ''' return libvlc_video_get_track_count(self) + def video_get_track(self): '''Get current video track. @return: the video track ID (int) or -1 if no active input. ''' return libvlc_video_get_track(self) + def video_set_track(self, i_track): '''Set video track. @param i_track: the track ID (i_id field from track description). @@ -3051,6 +3531,7 @@ class MediaPlayer(_Ctype): ''' return libvlc_video_set_track(self, i_track) + def video_take_snapshot(self, num, psz_filepath, i_width, i_height): '''Take a snapshot of the current video window. If i_width AND i_height is 0, original size is used. @@ -3063,24 +3544,28 @@ class MediaPlayer(_Ctype): ''' return libvlc_video_take_snapshot(self, num, str_to_bytes(psz_filepath), i_width, i_height) + def video_set_deinterlace(self, psz_mode): '''Enable or disable deinterlace filter. - @param psz_mode: type of deinterlace filter, NULL to disable. + @param psz_mode: type of deinterlace filter, None to disable. ''' return libvlc_video_set_deinterlace(self, str_to_bytes(psz_mode)) + def video_get_marquee_int(self, option): '''Get an integer marquee option value. @param option: marq option to get See libvlc_video_marquee_int_option_t. ''' return libvlc_video_get_marquee_int(self, option) + def video_get_marquee_string(self, option): '''Get a string marquee option value. @param option: marq option to get See libvlc_video_marquee_string_option_t. ''' return libvlc_video_get_marquee_string(self, option) + def video_set_marquee_int(self, option, i_val): '''Enable, disable or set an integer marquee option Setting libvlc_marquee_Enable has the side effect of enabling (arg !0) @@ -3090,6 +3575,7 @@ class MediaPlayer(_Ctype): ''' return libvlc_video_set_marquee_int(self, option, i_val) + def video_set_marquee_string(self, option, psz_text): '''Set a marquee string option. @param option: marq option to set See libvlc_video_marquee_string_option_t. @@ -3097,12 +3583,14 @@ class MediaPlayer(_Ctype): ''' return libvlc_video_set_marquee_string(self, option, str_to_bytes(psz_text)) + def video_get_logo_int(self, option): '''Get integer logo option. @param option: logo option to get, values of libvlc_video_logo_option_t. ''' return libvlc_video_get_logo_int(self, option) + def video_set_logo_int(self, option, value): '''Set logo option as integer. Options that take a different type value are ignored. @@ -3113,6 +3601,7 @@ class MediaPlayer(_Ctype): ''' return libvlc_video_set_logo_int(self, option, value) + def video_set_logo_string(self, option, psz_value): '''Set logo option as string. Options that take a different type value are ignored. @@ -3121,6 +3610,7 @@ class MediaPlayer(_Ctype): ''' return libvlc_video_set_logo_string(self, option, str_to_bytes(psz_value)) + def video_get_adjust_int(self, option): '''Get integer adjust option. @param option: adjust option to get, values of libvlc_video_adjust_option_t. @@ -3128,6 +3618,7 @@ class MediaPlayer(_Ctype): ''' return libvlc_video_get_adjust_int(self, option) + def video_set_adjust_int(self, option, value): '''Set adjust option as integer. Options that take a different type value are ignored. @@ -3139,6 +3630,7 @@ class MediaPlayer(_Ctype): ''' return libvlc_video_set_adjust_int(self, option, value) + def video_get_adjust_float(self, option): '''Get float adjust option. @param option: adjust option to get, values of libvlc_video_adjust_option_t. @@ -3146,6 +3638,7 @@ class MediaPlayer(_Ctype): ''' return libvlc_video_get_adjust_float(self, option) + def video_set_adjust_float(self, option, value): '''Set adjust option as float. Options that take a different type value are ignored. @@ -3155,6 +3648,7 @@ class MediaPlayer(_Ctype): ''' return libvlc_video_set_adjust_float(self, option, value) + def audio_output_set(self, psz_name): '''Selects an audio output module. @note: Any change will take be effect only after playback is stopped and @@ -3164,31 +3658,33 @@ class MediaPlayer(_Ctype): ''' return libvlc_audio_output_set(self, str_to_bytes(psz_name)) + def audio_output_device_enum(self): '''Gets a list of potential audio output devices, See L{audio_output_device_set}(). @note: Not all audio outputs support enumerating devices. - The audio output may be functional even if the list is empty (NULL). + The audio output may be functional even if the list is empty (None). @note: The list may not be exhaustive. @warning: Some audio output devices in the list might not actually work in some circumstances. By default, it is recommended to not specify any explicit audio device. - @return: A NULL-terminated linked list of potential audio output devices. It must be freed it with L{audio_output_device_list_release}(). + @return: A None-terminated linked list of potential audio output devices. It must be freed with L{audio_output_device_list_release}(). @version: LibVLC 2.2.0 or later. ''' return libvlc_audio_output_device_enum(self) + def audio_output_device_set(self, module, device_id): '''Configures an explicit audio output device. - If the module paramater is NULL, audio output will be moved to the device + If the module paramater is None, audio output will be moved to the device specified by the device identifier string immediately. This is the recommended usage. A list of adequate potential device strings can be obtained with L{audio_output_device_enum}(). - However passing NULL is supported in LibVLC version 2.2.0 and later only; + However passing None is supported in LibVLC version 2.2.0 and later only; in earlier versions, this function would have no effects when the module - parameter was NULL. - If the module parameter is not NULL, the device parameter of the + parameter was None. + If the module parameter is not None, the device parameter of the corresponding audio output, if it exists, will be set to the specified string. Note that some audio output modules do not have such a parameter (notably MMDevice and PulseAudio). @@ -3199,35 +3695,58 @@ class MediaPlayer(_Ctype): @warning: The syntax for the device parameter depends on the audio output. Some audio output modules require further parameters (e.g. a channels map in the case of ALSA). - @param module: If NULL, current audio output module. if non-NULL, name of audio output module. + @param module: If None, current audio output module. if non-None, name of audio output module. @param device_id: device identifier string. @return: Nothing. Errors are ignored (this is a design bug). ''' return libvlc_audio_output_device_set(self, str_to_bytes(module), str_to_bytes(device_id)) + + def audio_output_device_get(self): + '''Get the current audio output device identifier. + This complements L{audio_output_device_set}(). + @warning: The initial value for the current audio output device identifier + may not be set or may be some unknown value. A LibVLC application should + compare this value against the known device identifiers (e.g. those that + were previously retrieved by a call to L{audio_output_device_enum} or + L{audio_output_device_list_get}) to find the current audio output device. + It is possible that the selected audio output device changes (an external + change) without a call to L{audio_output_device_set}. That may make this + method unsuitable to use if a LibVLC application is attempting to track + dynamic audio device changes as they happen. + @return: the current audio output device identifier None if no device is selected or in case of error (the result must be released with free() or L{free}()). + @version: LibVLC 3.0.0 or later. + ''' + return libvlc_audio_output_device_get(self) + + def audio_toggle_mute(self): '''Toggle mute status. ''' return libvlc_audio_toggle_mute(self) + def audio_get_mute(self): '''Get current mute status. @return: the mute status (boolean) if defined, -1 if undefined/unapplicable. ''' return libvlc_audio_get_mute(self) + def audio_set_mute(self, status): '''Set mute status. @param status: If status is true then mute, otherwise unmute @warning This function does not always work. If there are no active audio playback stream, the mute status might not be available. If digital pass-through (S/PDIF, HDMI...) is in use, muting may be unapplicable. Also some audio output plugins do not support muting at all. @note To force silent playback, disable all audio tracks. This is more efficient and reliable than mute. ''' return libvlc_audio_set_mute(self, status) + def audio_get_volume(self): '''Get current software audio volume. @return: the software volume in percents (0 = mute, 100 = nominal / 0dB). ''' return libvlc_audio_get_volume(self) + def audio_set_volume(self, i_volume): '''Set current software audio volume. @param i_volume: the volume in percents (0 = mute, 100 = 0dB). @@ -3235,18 +3754,21 @@ class MediaPlayer(_Ctype): ''' return libvlc_audio_set_volume(self, i_volume) + def audio_get_track_count(self): '''Get number of available audio tracks. @return: the number of available audio tracks (int), or -1 if unavailable. ''' return libvlc_audio_get_track_count(self) + def audio_get_track(self): '''Get current audio track. @return: the audio track ID or -1 if no active input. ''' return libvlc_audio_get_track(self) + def audio_set_track(self, i_track): '''Set current audio track. @param i_track: the track ID (i_id field from track description). @@ -3254,12 +3776,14 @@ class MediaPlayer(_Ctype): ''' return libvlc_audio_set_track(self, i_track) + def audio_get_channel(self): '''Get current audio channel. @return: the audio channel See libvlc_audio_output_channel_t. ''' return libvlc_audio_get_channel(self) + def audio_set_channel(self, channel): '''Set current audio channel. @param channel: the audio channel, See libvlc_audio_output_channel_t. @@ -3267,6 +3791,7 @@ class MediaPlayer(_Ctype): ''' return libvlc_audio_set_channel(self, channel) + def audio_get_delay(self): '''Get current audio delay. @return: the audio delay (microseconds). @@ -3274,6 +3799,7 @@ class MediaPlayer(_Ctype): ''' return libvlc_audio_get_delay(self) + def audio_set_delay(self, i_delay): '''Set current audio delay. The audio delay will be reset to zero each time the media changes. @param i_delay: the audio delay (microseconds). @@ -3282,6 +3808,7 @@ class MediaPlayer(_Ctype): ''' return libvlc_audio_set_delay(self, i_delay) + def set_equalizer(self, p_equalizer): '''Apply new equalizer settings to a media player. The equalizer is first created by invoking L{audio_equalizer_new}() or @@ -3293,12 +3820,12 @@ class MediaPlayer(_Ctype): If there is no currently playing media, the new equalizer settings will be applied later if and when new media is played. Equalizer settings will automatically be applied to subsequently played media. - To disable the equalizer for a media player invoke this method passing NULL for the + To disable the equalizer for a media player invoke this method passing None for the p_equalizer parameter. The media player does not keep a reference to the supplied equalizer so it is safe for an application to release the equalizer reference any time after this method returns. - @param p_equalizer: opaque equalizer handle, or NULL to disable the equalizer for this media player. + @param p_equalizer: opaque equalizer handle, or None to disable the equalizer for this media player. @return: zero on success, -1 on error. @version: LibVLC 2.2.0 or later. ''' @@ -3312,7 +3839,7 @@ def libvlc_errmsg(): thread. The resulting string is valid until another error occurs (at least until the next LibVLC call). @warning - This will be NULL if there was no error. + This will be None if there was no error. ''' f = _Cfunctions.get('libvlc_errmsg', None) or \ _Cfunction('libvlc_errmsg', (), None, @@ -3345,10 +3872,31 @@ def libvlc_new(argc, argv): '''Create and initialize a libvlc instance. This functions accept a list of "command line" arguments similar to the main(). These arguments affect the LibVLC instance default configuration. + @note + LibVLC may create threads. Therefore, any thread-unsafe process + initialization must be performed before calling L{libvlc_new}(). In particular + and where applicable: + - setlocale() and textdomain(), + - setenv(), unsetenv() and putenv(), + - with the X11 display system, XInitThreads() + (see also L{libvlc_media_player_set_xwindow}()) and + - on Microsoft Windows, SetErrorMode(). + - sigprocmask() shall never be invoked; pthread_sigmask() can be used. + On POSIX systems, the SIGCHLD signal must B{not} be ignored, i.e. the + signal handler must set to SIG_DFL or a function pointer, not SIG_IGN. + Also while LibVLC is active, the wait() function shall not be called, and + any call to waitpid() shall use a strictly positive value for the first + parameter (i.e. the PID). Failure to follow those rules may lead to a + deadlock or a busy loop. + Also on POSIX systems, it is recommended that the SIGPIPE signal be blocked, + even if it is not, in principles, necessary. + On Microsoft Windows Vista/2008, the process error mode + SEM_FAILCRITICALERRORS flag B{must} with the SetErrorMode() function + before using LibVLC. On later versions, it is optional and unnecessary. @param argc: the number of arguments (should be 0). - @param argv: list of arguments (should be NULL). - @return: the libvlc instance or NULL in case of error. - @version Arguments are meant to be passed from the command line to LibVLC, just like VLC media player does. The list of valid arguments depends on the LibVLC version, the operating system and platform, and set of available LibVLC plugins. Invalid or unsupported arguments will cause the function to fail (i.e. return NULL). Also, some arguments may alter the behaviour or otherwise interfere with other LibVLC functions. @warning There is absolutely no warranty or promise of forward, backward and cross-platform compatibility with regards to L{libvlc_new}() arguments. We recommend that you do not use them, other than when debugging. + @param argv: list of arguments (should be None). + @return: the libvlc instance or None in case of error. + @version Arguments are meant to be passed from the command line to LibVLC, just like VLC media player does. The list of valid arguments depends on the LibVLC version, the operating system and platform, and set of available LibVLC plugins. Invalid or unsupported arguments will cause the function to fail (i.e. return None). Also, some arguments may alter the behaviour or otherwise interfere with other LibVLC functions. @warning There is absolutely no warranty or promise of forward, backward and cross-platform compatibility with regards to L{libvlc_new}() arguments. We recommend that you do not use them, other than when debugging. ''' f = _Cfunctions.get('libvlc_new', None) or \ _Cfunction('libvlc_new', ((1,), (1,),), class_result(Instance), @@ -3378,7 +3926,7 @@ def libvlc_retain(p_instance): def libvlc_add_intf(p_instance, name): '''Try to start a user interface for the libvlc instance. @param p_instance: the instance. - @param name: interface name, or NULL for default. + @param name: interface name, or None for default. @return: 0 on success, -1 on error. ''' f = _Cfunctions.get('libvlc_add_intf', None) or \ @@ -3491,10 +4039,10 @@ def libvlc_event_type_name(event_type): def libvlc_log_get_context(ctx): '''Gets debugging information about a log message: the name of the VLC module emitting the message and the message location within the source code. - The returned module name and file name will be NULL if unknown. + The returned module name and file name will be None if unknown. The returned line number will similarly be zero if unknown. @param ctx: message context (as passed to the @ref libvlc_log_cb callback). - @return: module module name storage (or NULL), file source code file name storage (or NULL), line source code file line number storage (or NULL). + @return: module module name storage (or None), file source code file name storage (or None), line source code file line number storage (or None). @version: LibVLC 2.1.0 or later. ''' f = _Cfunctions.get('libvlc_log_get_context', None) or \ @@ -3507,13 +4055,13 @@ def libvlc_log_get_object(ctx, id): object emitting the message, the object header if any and a temporaly-unique object identifier. This information is mainly meant for B{manual} troubleshooting. - The returned type name may be "generic" if unknown, but it cannot be NULL. - The returned header will be NULL if unset; in current versions, the header + The returned type name may be "generic" if unknown, but it cannot be None. + The returned header will be None if unset; in current versions, the header is used to distinguish for VLM inputs. The returned object ID will be zero if the message is not associated with any VLC object. @param ctx: message context (as passed to the @ref libvlc_log_cb callback). - @return: name object name storage (or NULL), header object header (or NULL), line source code file line number storage (or NULL). + @return: name object name storage (or None), header object header (or None), line source code file line number storage (or None). @version: LibVLC 2.1.0 or later. ''' f = _Cfunctions.get('libvlc_log_get_object', None) or \ @@ -3571,7 +4119,7 @@ def libvlc_module_description_list_release(p_list): def libvlc_audio_filter_list_get(p_instance): '''Returns a list of audio filters that are available. @param p_instance: libvlc instance. - @return: a list of module descriptions. It should be freed with L{libvlc_module_description_list_release}(). In case of an error, NULL is returned. See L{ModuleDescription} See L{libvlc_module_description_list_release}. + @return: a list of module descriptions. It should be freed with L{libvlc_module_description_list_release}(). In case of an error, None is returned. See L{ModuleDescription} See L{libvlc_module_description_list_release}. ''' f = _Cfunctions.get('libvlc_audio_filter_list_get', None) or \ _Cfunction('libvlc_audio_filter_list_get', ((1,),), None, @@ -3581,7 +4129,7 @@ def libvlc_audio_filter_list_get(p_instance): def libvlc_video_filter_list_get(p_instance): '''Returns a list of video filters that are available. @param p_instance: libvlc instance. - @return: a list of module descriptions. It should be freed with L{libvlc_module_description_list_release}(). In case of an error, NULL is returned. See L{ModuleDescription} See L{libvlc_module_description_list_release}. + @return: a list of module descriptions. It should be freed with L{libvlc_module_description_list_release}(). In case of an error, None is returned. See L{ModuleDescription} See L{libvlc_module_description_list_release}. ''' f = _Cfunctions.get('libvlc_video_filter_list_get', None) or \ _Cfunction('libvlc_video_filter_list_get', ((1,),), None, @@ -3611,7 +4159,7 @@ def libvlc_media_new_location(p_instance, psz_mrl): See L{libvlc_media_release}. @param p_instance: the instance. @param psz_mrl: the media location. - @return: the newly created media or NULL on error. + @return: the newly created media or None on error. ''' f = _Cfunctions.get('libvlc_media_new_location', None) or \ _Cfunction('libvlc_media_new_location', ((1,), (1,),), class_result(Media), @@ -3623,7 +4171,7 @@ def libvlc_media_new_path(p_instance, path): See L{libvlc_media_release}. @param p_instance: the instance. @param path: local filesystem path. - @return: the newly created media or NULL on error. + @return: the newly created media or None on error. ''' f = _Cfunctions.get('libvlc_media_new_path', None) or \ _Cfunction('libvlc_media_new_path', ((1,), (1,),), class_result(Media), @@ -3646,7 +4194,7 @@ def libvlc_media_new_fd(p_instance, fd): See L{libvlc_media_release}. @param p_instance: the instance. @param fd: open file descriptor. - @return: the newly created media or NULL on error. + @return: the newly created media or None on error. @version: LibVLC 1.1.5 and later. ''' f = _Cfunctions.get('libvlc_media_new_fd', None) or \ @@ -3654,12 +4202,28 @@ def libvlc_media_new_fd(p_instance, fd): ctypes.c_void_p, Instance, ctypes.c_int) return f(p_instance, fd) +def libvlc_media_new_callbacks(instance, open_cb, read_cb, seek_cb, close_cb, opaque): + '''Create a media with custom callbacks to read the data from. + @param instance: LibVLC instance. + @param open_cb: callback to open the custom bitstream input media. + @param read_cb: callback to read data (must not be None). + @param seek_cb: callback to seek, or None if seeking is not supported. + @param close_cb: callback to close the media, or None if unnecessary. + @param opaque: data pointer for the open callback. + @return: the newly created media or None on error @note If open_cb is None, the opaque pointer will be passed to read_cb, seek_cb and close_cb, and the stream size will be treated as unknown. @note The callbacks may be called asynchronously (from another thread). A single stream instance need not be reentrant. However the open_cb needs to be reentrant if the media is used by multiple player instances. @warning The callbacks may be used until all or any player instances that were supplied the media item are stopped. See L{libvlc_media_release}. + @version: LibVLC 3.0.0 and later. + ''' + f = _Cfunctions.get('libvlc_media_new_callbacks', None) or \ + _Cfunction('libvlc_media_new_callbacks', ((1,), (1,), (1,), (1,), (1,), (1,),), class_result(Media), + ctypes.c_void_p, Instance, MediaOpenCb, MediaReadCb, MediaSeekCb, MediaCloseCb, ctypes.c_void_p) + return f(instance, open_cb, read_cb, seek_cb, close_cb, opaque) + def libvlc_media_new_as_node(p_instance, psz_name): '''Create a media as an empty node with a given name. See L{libvlc_media_release}. @param p_instance: the instance. @param psz_name: the name of the node. - @return: the new empty media or NULL on error. + @return: the new empty media or None on error. ''' f = _Cfunctions.get('libvlc_media_new_as_node', None) or \ _Cfunction('libvlc_media_new_as_node', ((1,), (1,),), class_result(Media), @@ -3750,7 +4314,7 @@ def libvlc_media_duplicate(p_md): def libvlc_media_get_meta(p_md, e_meta): '''Read the meta of the media. - If the media has not yet been parsed this will return NULL. + If the media has not yet been parsed this will return None. This methods automatically calls L{libvlc_media_parse_async}(), so after calling it you may receive a libvlc_MediaMetaChanged event. If you prefer a synchronous version ensure that you call L{libvlc_media_parse}() before get_meta(). @@ -3819,7 +4383,7 @@ def libvlc_media_subitems(p_md): the reference count of supplied media descriptor object. Use L{libvlc_media_list_release}() to decrement the reference counting. @param p_md: media descriptor object. - @return: list of media descriptor subitems or NULL. + @return: list of media descriptor subitems or None. ''' f = _Cfunctions.get('libvlc_media_subitems', None) or \ _Cfunction('libvlc_media_subitems', ((1,),), class_result(MediaList), @@ -3849,7 +4413,7 @@ def libvlc_media_get_duration(p_md): def libvlc_media_parse(p_md): '''Parse a media. - This fetches (local) meta data and tracks information. + This fetches (local) art, meta data and tracks information. The method is synchronous. See L{libvlc_media_parse_async} See L{libvlc_media_get_meta} @@ -3863,7 +4427,7 @@ def libvlc_media_parse(p_md): def libvlc_media_parse_async(p_md): '''Parse a media. - This fetches (local) meta data and tracks information. + This fetches (local) art, meta data and tracks information. The method is the asynchronous of L{libvlc_media_parse}(). To track when this is over you can listen to libvlc_MediaParsedChanged event. However if the media was already parsed you will not receive this @@ -3879,6 +4443,30 @@ def libvlc_media_parse_async(p_md): None, Media) return f(p_md) +def libvlc_media_parse_with_options(p_md, parse_flag): + '''Parse the media asynchronously with options. + This fetches (local or network) art, meta data and/or tracks information. + This method is the extended version of L{libvlc_media_parse_async}(). + To track when this is over you can listen to libvlc_MediaParsedChanged + event. However if this functions returns an error, you will not receive this + event. + It uses a flag to specify parse options (see libvlc_media_parse_flag_t). All + these flags can be combined. By default, media is parsed if it's a local + file. + See libvlc_MediaParsedChanged + See L{libvlc_media_get_meta} + See L{libvlc_media_tracks_get} + See libvlc_media_parse_flag_t. + @param p_md: media descriptor object. + @param parse_flag: parse options: + @return: -1 in case of error, 0 otherwise. + @version: LibVLC 3.0.0 or later. + ''' + f = _Cfunctions.get('libvlc_media_parse_with_options', None) or \ + _Cfunction('libvlc_media_parse_with_options', ((1,), (1,),), None, + ctypes.c_int, Media, MediaParseFlag) + return f(p_md, parse_flag) + def libvlc_media_is_parsed(p_md): '''Get Parsed status for media descriptor object. See libvlc_MediaParsedChanged. @@ -3928,6 +4516,18 @@ def libvlc_media_tracks_get(p_md, tracks): ctypes.c_uint, Media, ctypes.POINTER(ctypes.POINTER(MediaTrack))) return f(p_md, tracks) +def libvlc_media_get_codec_description(i_type, i_codec): + '''Get codec description from media elementary stream. + @param i_type: i_type from L{MediaTrack}. + @param i_codec: i_codec or i_original_fourcc from L{MediaTrack}. + @return: codec description. + @version: LibVLC 3.0.0 and later. See L{MediaTrack}. + ''' + f = _Cfunctions.get('libvlc_media_get_codec_description', None) or \ + _Cfunction('libvlc_media_get_codec_description', ((1,), (1,),), None, + ctypes.c_char_p, TrackType, ctypes.c_uint32) + return f(i_type, i_codec) + def libvlc_media_tracks_release(p_tracks, i_count): '''Release media descriptor's elementary streams description array. @param p_tracks: tracks info array to release. @@ -3939,17 +4539,63 @@ def libvlc_media_tracks_release(p_tracks, i_count): None, ctypes.POINTER(MediaTrack), ctypes.c_uint) return f(p_tracks, i_count) -def libvlc_media_discoverer_new_from_name(p_inst, psz_name): - '''Discover media service by name. +def libvlc_media_get_type(p_md): + '''Get the media type of the media descriptor object. + @param p_md: media descriptor object. + @return: media type. + @version: LibVLC 3.0.0 and later. See libvlc_media_type_t. + ''' + f = _Cfunctions.get('libvlc_media_get_type', None) or \ + _Cfunction('libvlc_media_get_type', ((1,),), None, + MediaType, Media) + return f(p_md) + +def libvlc_media_discoverer_new(p_inst, psz_name): + '''Create a media discoverer object by name. + After this object is created, you should attach to events in order to be + notified of the discoverer state. + You should also attach to media_list events in order to be notified of new + items discovered. + You need to call L{libvlc_media_discoverer_start}() in order to start the + discovery. + See L{libvlc_media_discoverer_media_list} + See L{libvlc_media_discoverer_event_manager} + See L{libvlc_media_discoverer_start}. @param p_inst: libvlc instance. @param psz_name: service name. - @return: media discover object or NULL in case of error. + @return: media discover object or None in case of error. + @version: LibVLC 3.0.0 or later. ''' - f = _Cfunctions.get('libvlc_media_discoverer_new_from_name', None) or \ - _Cfunction('libvlc_media_discoverer_new_from_name', ((1,), (1,),), class_result(MediaDiscoverer), + f = _Cfunctions.get('libvlc_media_discoverer_new', None) or \ + _Cfunction('libvlc_media_discoverer_new', ((1,), (1,),), class_result(MediaDiscoverer), ctypes.c_void_p, Instance, ctypes.c_char_p) return f(p_inst, psz_name) +def libvlc_media_discoverer_start(p_mdis): + '''Start media discovery. + To stop it, call L{libvlc_media_discoverer_stop}() or + L{libvlc_media_discoverer_release}() directly. + See L{libvlc_media_discoverer_stop}. + @param p_mdis: media discover object. + @return: -1 in case of error, 0 otherwise. + @version: LibVLC 3.0.0 or later. + ''' + f = _Cfunctions.get('libvlc_media_discoverer_start', None) or \ + _Cfunction('libvlc_media_discoverer_start', ((1,),), None, + ctypes.c_int, MediaDiscoverer) + return f(p_mdis) + +def libvlc_media_discoverer_stop(p_mdis): + '''Stop media discovery. + See L{libvlc_media_discoverer_start}. + @param p_mdis: media discover object. + @version: LibVLC 3.0.0 or later. + ''' + f = _Cfunctions.get('libvlc_media_discoverer_stop', None) or \ + _Cfunction('libvlc_media_discoverer_stop', ((1,),), None, + None, MediaDiscoverer) + return f(p_mdis) + def libvlc_media_discoverer_release(p_mdis): '''Release media discover object. If the reference count reaches 0, then the object will be released. @@ -4003,7 +4649,7 @@ def libvlc_media_discoverer_is_running(p_mdis): def libvlc_media_library_new(p_instance): '''Create an new Media Library object. @param p_instance: the libvlc instance. - @return: a new object or NULL on error. + @return: a new object or None on error. ''' f = _Cfunctions.get('libvlc_media_library_new', None) or \ _Cfunction('libvlc_media_library_new', ((1,),), class_result(MediaLibrary), @@ -4055,7 +4701,7 @@ def libvlc_media_library_media_list(p_mlib): def libvlc_media_list_new(p_instance): '''Create an empty media list. @param p_instance: libvlc instance. - @return: empty media list, or NULL on error. + @return: empty media list, or None on error. ''' f = _Cfunctions.get('libvlc_media_list_new', None) or \ _Cfunction('libvlc_media_list_new', ((1,),), class_result(MediaList), @@ -4157,7 +4803,7 @@ def libvlc_media_list_item_at_index(p_ml, i_pos): The L{libvlc_media_list_lock} should be held upon entering this function. @param p_ml: a media list instance. @param i_pos: position in array where to insert. - @return: media instance at position i_pos, or NULL if not found. In case of success, L{libvlc_media_retain}() is called to increase the refcount on the media. + @return: media instance at position i_pos, or None if not found. In case of success, L{libvlc_media_retain}() is called to increase the refcount on the media. ''' f = _Cfunctions.get('libvlc_media_list_item_at_index', None) or \ _Cfunction('libvlc_media_list_item_at_index', ((1,), (1,),), class_result(Media), @@ -4220,7 +4866,7 @@ def libvlc_media_list_event_manager(p_ml): def libvlc_media_list_player_new(p_instance): '''Create new media_list_player. @param p_instance: libvlc instance. - @return: media list player instance or NULL on error. + @return: media list player instance or None on error. ''' f = _Cfunctions.get('libvlc_media_list_player_new', None) or \ _Cfunction('libvlc_media_list_player_new', ((1,),), class_result(MediaListPlayer), @@ -4270,6 +4916,16 @@ def libvlc_media_list_player_set_media_player(p_mlp, p_mi): None, MediaListPlayer, MediaPlayer) return f(p_mlp, p_mi) +def libvlc_media_list_player_get_media_player(p_mlp): + '''Get media player of the media_list_player instance. + @param p_mlp: media list player instance. + @return: media player instance @note the caller is responsible for releasing the returned instance. + ''' + f = _Cfunctions.get('libvlc_media_list_player_get_media_player', None) or \ + _Cfunction('libvlc_media_list_player_get_media_player', ((1,),), class_result(MediaPlayer), + ctypes.c_void_p, MediaListPlayer) + return f(p_mlp) + def libvlc_media_list_player_set_media_list(p_mlp, p_mlist): '''Set the media list associated with the player. @param p_mlp: media list player instance. @@ -4382,7 +5038,7 @@ def libvlc_media_list_player_set_playback_mode(p_mlp, e_mode): def libvlc_media_player_new(p_libvlc_instance): '''Create an empty Media Player object. @param p_libvlc_instance: the libvlc instance in which the Media Player should be created. - @return: a new media player object, or NULL on error. + @return: a new media player object, or None on error. ''' f = _Cfunctions.get('libvlc_media_player_new', None) or \ _Cfunction('libvlc_media_player_new', ((1,),), class_result(MediaPlayer), @@ -4392,7 +5048,7 @@ def libvlc_media_player_new(p_libvlc_instance): def libvlc_media_player_new_from_media(p_md): '''Create a Media Player object from a Media. @param p_md: the media. Afterwards the p_md can be safely destroyed. - @return: a new media player object, or NULL on error. + @return: a new media player object, or None on error. ''' f = _Cfunctions.get('libvlc_media_player_new_from_media', None) or \ _Cfunction('libvlc_media_player_new_from_media', ((1,),), class_result(MediaPlayer), @@ -4436,7 +5092,7 @@ def libvlc_media_player_set_media(p_mi, p_md): def libvlc_media_player_get_media(p_mi): '''Get the media used by the media_player. @param p_mi: the Media Player. - @return: the media associated with p_mi, or NULL if no media is associated. + @return: the media associated with p_mi, or None if no media is associated. ''' f = _Cfunctions.get('libvlc_media_player_get_media', None) or \ _Cfunction('libvlc_media_player_get_media', ((1,),), class_result(Media), @@ -4508,9 +5164,9 @@ def libvlc_video_set_callbacks(mp, lock, unlock, display, opaque): Use L{libvlc_video_set_format}() or L{libvlc_video_set_format_callbacks}() to configure the decoded format. @param mp: the media player. - @param lock: callback to lock video memory (must not be NULL). - @param unlock: callback to unlock video memory (or NULL if not needed). - @param display: callback to display video (or NULL if not needed). + @param lock: callback to lock video memory (must not be None). + @param unlock: callback to unlock video memory (or None if not needed). + @param display: callback to display video (or None if not needed). @param opaque: private pointer for the three callbacks (as first parameter). @version: LibVLC 1.1.1 or later. ''' @@ -4540,8 +5196,8 @@ def libvlc_video_set_format_callbacks(mp, setup, cleanup): '''Set decoded video chroma and dimensions. This only works in combination with L{libvlc_video_set_callbacks}(). @param mp: the media player. - @param setup: callback to select the video format (cannot be NULL). - @param cleanup: callback to release any allocated resources (or NULL). + @param setup: callback to select the video format (cannot be None). + @param cleanup: callback to release any allocated resources (or None). @version: LibVLC 2.0.0 or later. ''' f = _Cfunctions.get('libvlc_video_set_format_callbacks', None) or \ @@ -4554,7 +5210,7 @@ def libvlc_media_player_set_nsobject(p_mi, drawable): Use the vout called "macosx". The drawable is an NSObject that follow the VLCOpenGLVideoViewEmbedding protocol: - @begincode + @code.m \@protocol VLCOpenGLVideoViewEmbedding - (void)addVoutSubview:(NSView *)view; - (void)removeVoutSubview:(NSView *)view; @@ -4563,13 +5219,13 @@ def libvlc_media_player_set_nsobject(p_mi, drawable): Or it can be an NSView object. If you want to use it along with Qt4 see the QMacCocoaViewContainer. Then the following code should work: - @begincode - + @code.mm + NSView *video = [[NSView alloc] init]; QMacCocoaViewContainer *container = new QMacCocoaViewContainer(video, parent); L{libvlc_media_player_set_nsobject}(mp, video); [video release]; - + @endcode You can find a live example in VLCVideoView in VLCKit.framework. @param p_mi: the Media Player. @@ -4591,9 +5247,7 @@ def libvlc_media_player_get_nsobject(p_mi): return f(p_mi) def libvlc_media_player_set_agl(p_mi, drawable): - '''Set the agl handler where the media player should render its video output. - @param p_mi: the Media Player. - @param drawable: the agl handler. + '''\deprecated Use L{libvlc_media_player_set_nsobject} instead. ''' f = _Cfunctions.get('libvlc_media_player_set_agl', None) or \ _Cfunction('libvlc_media_player_set_agl', ((1,), (1,),), None, @@ -4601,9 +5255,7 @@ def libvlc_media_player_set_agl(p_mi, drawable): return f(p_mi, drawable) def libvlc_media_player_get_agl(p_mi): - '''Get the agl handler previously set with L{libvlc_media_player_set_agl}(). - @param p_mi: the Media Player. - @return: the agl handler or 0 if none where set. + '''\deprecated Use L{libvlc_media_player_get_nsobject} instead. ''' f = _Cfunctions.get('libvlc_media_player_get_agl', None) or \ _Cfunction('libvlc_media_player_get_agl', ((1,),), None, @@ -4612,15 +5264,24 @@ def libvlc_media_player_get_agl(p_mi): def libvlc_media_player_set_xwindow(p_mi, drawable): '''Set an X Window System drawable where the media player should render its - video output. If LibVLC was built without X11 output support, then this has - no effects. - The specified identifier must correspond to an existing Input/Output class - X11 window. Pixmaps are B{not} supported. The caller shall ensure that - the X11 server is the same as the one the VLC instance has been configured - with. This function must be called before video playback is started; - otherwise it will only take effect after playback stop and restart. - @param p_mi: the Media Player. - @param drawable: the ID of the X window. + video output. The call takes effect when the playback starts. If it is + already started, it might need to be stopped before changes apply. + If LibVLC was built without X11 output support, then this function has no + effects. + By default, LibVLC will capture input events on the video rendering area. + Use L{libvlc_video_set_mouse_input}() and L{libvlc_video_set_key_input}() to + disable that and deliver events to the parent window / to the application + instead. By design, the X11 protocol delivers input events to only one + recipient. + @warning + The application must call the XInitThreads() function from Xlib before + L{libvlc_new}(), and before any call to XOpenDisplay() directly or via any + other library. Failure to call XInitThreads() will seriously impede LibVLC + performance. Calling XOpenDisplay() before XInitThreads() will eventually + crash the process. That is a limitation of Xlib. + @param p_mi: media player. + @param drawable: X11 window ID @note The specified identifier must correspond to an existing Input/Output class X11 window. Pixmaps are B{not} currently supported. The default X11 server is assumed, i.e. that specified in the DISPLAY environment variable. @warning LibVLC can deal with invalid X11 handle errors, however some display drivers (EGL, GLX, VA and/or VDPAU) can unfortunately not. Thus the window handle must remain valid until playback is stopped, otherwise the process may abort or crash. + @bug No more than one window handle per media player instance can be specified. If the media has multiple simultaneously active video tracks, extra tracks will be rendered into external windows beyond the control of the application. ''' f = _Cfunctions.get('libvlc_media_player_set_xwindow', None) or \ _Cfunction('libvlc_media_player_set_xwindow', ((1,), (1,),), None, @@ -4657,23 +5318,35 @@ def libvlc_media_player_get_hwnd(p_mi): L{libvlc_media_player_set_hwnd}(). The handle will be returned even if LibVLC is not currently outputting any video to it. @param p_mi: the Media Player. - @return: a window handle or NULL if there are none. + @return: a window handle or None if there are none. ''' f = _Cfunctions.get('libvlc_media_player_get_hwnd', None) or \ _Cfunction('libvlc_media_player_get_hwnd', ((1,),), None, ctypes.c_void_p, MediaPlayer) return f(p_mi) +def libvlc_media_player_set_android_context(p_mi, p_jvm, p_awindow_handler): + '''Set the android context. + @param p_mi: the media player. + @param p_jvm: the Java VM of the android process. + @param awindow_handler: org.videolan.libvlc.IAWindowNativeHandler jobject implemented by the org.videolan.libvlc.MediaPlayer class from the libvlc-android project. + @version: LibVLC 3.0.0 and later. + ''' + f = _Cfunctions.get('libvlc_media_player_set_android_context', None) or \ + _Cfunction('libvlc_media_player_set_android_context', ((1,), (1,), (1,),), None, + None, MediaPlayer, ctypes.c_void_p, ctypes.c_void_p) + return f(p_mi, p_jvm, p_awindow_handler) + def libvlc_audio_set_callbacks(mp, play, pause, resume, flush, drain, opaque): '''Set callbacks and private data for decoded audio. Use L{libvlc_audio_set_format}() or L{libvlc_audio_set_format_callbacks}() to configure the decoded audio format. @param mp: the media player. - @param play: callback to play audio samples (must not be NULL). - @param pause: callback to pause playback (or NULL to ignore). - @param resume: callback to resume playback (or NULL to ignore). - @param flush: callback to flush audio buffers (or NULL to ignore). - @param drain: callback to drain audio buffers (or NULL to ignore). + @param play: callback to play audio samples (must not be None). + @param pause: callback to pause playback (or None to ignore). + @param resume: callback to resume playback (or None to ignore). + @param flush: callback to flush audio buffers (or None to ignore). + @param drain: callback to drain audio buffers (or None to ignore). @param opaque: private pointer for the audio callbacks (as first parameter). @version: LibVLC 2.0.0 or later. ''' @@ -4683,11 +5356,12 @@ def libvlc_audio_set_callbacks(mp, play, pause, resume, flush, drain, opaque): return f(mp, play, pause, resume, flush, drain, opaque) def libvlc_audio_set_volume_callback(mp, set_volume): - '''Set callbacks and private data for decoded audio. + '''Set callbacks and private data for decoded audio. This only works in + combination with L{libvlc_audio_set_callbacks}(). Use L{libvlc_audio_set_format}() or L{libvlc_audio_set_format_callbacks}() to configure the decoded audio format. @param mp: the media player. - @param set_volume: callback to apply audio volume, or NULL to apply volume in software. + @param set_volume: callback to apply audio volume, or None to apply volume in software. @version: LibVLC 2.0.0 or later. ''' f = _Cfunctions.get('libvlc_audio_set_volume_callback', None) or \ @@ -4699,8 +5373,8 @@ def libvlc_audio_set_format_callbacks(mp, setup, cleanup): '''Set decoded audio format. This only works in combination with L{libvlc_audio_set_callbacks}(). @param mp: the media player. - @param setup: callback to select the audio format (cannot be NULL). - @param cleanup: callback to release any allocated resources (or NULL). + @param setup: callback to select the audio format (cannot be None). + @param cleanup: callback to release any allocated resources (or None). @version: LibVLC 2.0.0 or later. ''' f = _Cfunctions.get('libvlc_audio_set_format_callbacks', None) or \ @@ -5128,7 +5802,7 @@ def libvlc_video_set_scale(p_mi, f_factor): def libvlc_video_get_aspect_ratio(p_mi): '''Get current video aspect ratio. @param p_mi: the media player. - @return: the video aspect ratio or NULL if unspecified (the result must be released with free() or L{libvlc_free}()). + @return: the video aspect ratio or None if unspecified (the result must be released with free() or L{libvlc_free}()). ''' f = _Cfunctions.get('libvlc_video_get_aspect_ratio', None) or \ _Cfunction('libvlc_video_get_aspect_ratio', ((1,),), string_result, @@ -5138,7 +5812,7 @@ def libvlc_video_get_aspect_ratio(p_mi): def libvlc_video_set_aspect_ratio(p_mi, psz_aspect): '''Set new video aspect ratio. @param p_mi: the media player. - @param psz_aspect: new video aspect-ratio or NULL to reset to default @note Invalid aspect ratios are ignored. + @param psz_aspect: new video aspect-ratio or None to reset to default @note Invalid aspect ratios are ignored. ''' f = _Cfunctions.get('libvlc_video_set_aspect_ratio', None) or \ _Cfunction('libvlc_video_set_aspect_ratio', ((1,), (1,),), None, @@ -5168,7 +5842,7 @@ def libvlc_video_get_spu_count(p_mi): def libvlc_video_get_spu_description(p_mi): '''Get the description of available video subtitles. @param p_mi: the media player. - @return: list containing description of available video subtitles. + @return: list containing description of available video subtitles. It must be freed with L{libvlc_track_description_list_release}(). ''' f = _Cfunctions.get('libvlc_video_get_spu_description', None) or \ _Cfunction('libvlc_video_get_spu_description', ((1,),), None, @@ -5224,31 +5898,57 @@ def libvlc_video_set_spu_delay(p_mi, i_delay): ctypes.c_int, MediaPlayer, ctypes.c_int64) return f(p_mi, i_delay) -def libvlc_video_get_title_description(p_mi): - '''Get the description of available titles. +def libvlc_media_player_get_full_title_descriptions(p_mi, titles): + '''Get the full description of available titles. @param p_mi: the media player. - @return: list containing description of available titles. + @param address: to store an allocated array of title descriptions descriptions (must be freed with L{libvlc_title_descriptions_release}() by the caller) [OUT]. + @return: the number of titles (-1 on error). + @version: LibVLC 3.0.0 and later. ''' - f = _Cfunctions.get('libvlc_video_get_title_description', None) or \ - _Cfunction('libvlc_video_get_title_description', ((1,),), None, - ctypes.POINTER(TrackDescription), MediaPlayer) - return f(p_mi) + f = _Cfunctions.get('libvlc_media_player_get_full_title_descriptions', None) or \ + _Cfunction('libvlc_media_player_get_full_title_descriptions', ((1,), (1,),), None, + ctypes.c_int, MediaPlayer, ctypes.POINTER(ctypes.POINTER(TitleDescription))) + return f(p_mi, titles) -def libvlc_video_get_chapter_description(p_mi, i_title): - '''Get the description of available chapters for specific title. - @param p_mi: the media player. - @param i_title: selected title. - @return: list containing description of available chapter for title i_title. +def libvlc_title_descriptions_release(p_titles, i_count): + '''Release a title description. + @param title: description array to release. + @param number: of title descriptions to release. + @version: LibVLC 3.0.0 and later. ''' - f = _Cfunctions.get('libvlc_video_get_chapter_description', None) or \ - _Cfunction('libvlc_video_get_chapter_description', ((1,), (1,),), None, - ctypes.POINTER(TrackDescription), MediaPlayer, ctypes.c_int) - return f(p_mi, i_title) + f = _Cfunctions.get('libvlc_title_descriptions_release', None) or \ + _Cfunction('libvlc_title_descriptions_release', ((1,), (1,),), None, + None, ctypes.POINTER(TitleDescription), ctypes.c_uint) + return f(p_titles, i_count) + +def libvlc_media_player_get_full_chapter_descriptions(p_mi, i_chapters_of_title, pp_chapters): + '''Get the full description of available chapters. + @param p_mi: the media player. + @param index: of the title to query for chapters (uses current title if set to -1). + @param address: to store an allocated array of chapter descriptions descriptions (must be freed with L{libvlc_chapter_descriptions_release}() by the caller) [OUT]. + @return: the number of chapters (-1 on error). + @version: LibVLC 3.0.0 and later. + ''' + f = _Cfunctions.get('libvlc_media_player_get_full_chapter_descriptions', None) or \ + _Cfunction('libvlc_media_player_get_full_chapter_descriptions', ((1,), (1,), (1,),), None, + ctypes.c_int, MediaPlayer, ctypes.c_int, ctypes.POINTER(ctypes.POINTER(ChapterDescription))) + return f(p_mi, i_chapters_of_title, pp_chapters) + +def libvlc_chapter_descriptions_release(p_chapters, i_count): + '''Release a chapter description. + @param chapter: description array to release. + @param number: of chapter descriptions to release. + @version: LibVLC 3.0.0 and later. + ''' + f = _Cfunctions.get('libvlc_chapter_descriptions_release', None) or \ + _Cfunction('libvlc_chapter_descriptions_release', ((1,), (1,),), None, + None, ctypes.POINTER(ChapterDescription), ctypes.c_uint) + return f(p_chapters, i_count) def libvlc_video_get_crop_geometry(p_mi): '''Get current crop filter geometry. @param p_mi: the media player. - @return: the crop filter geometry or NULL if unset. + @return: the crop filter geometry or None if unset. ''' f = _Cfunctions.get('libvlc_video_get_crop_geometry', None) or \ _Cfunction('libvlc_video_get_crop_geometry', ((1,),), string_result, @@ -5258,7 +5958,7 @@ def libvlc_video_get_crop_geometry(p_mi): def libvlc_video_set_crop_geometry(p_mi, psz_geometry): '''Set new crop filter geometry. @param p_mi: the media player. - @param psz_geometry: new crop filter geometry (NULL to unset). + @param psz_geometry: new crop filter geometry (None to unset). ''' f = _Cfunctions.get('libvlc_video_set_crop_geometry', None) or \ _Cfunction('libvlc_video_set_crop_geometry', ((1,), (1,),), None, @@ -5307,7 +6007,7 @@ def libvlc_video_get_track_count(p_mi): def libvlc_video_get_track_description(p_mi): '''Get the description of available video tracks. @param p_mi: media player. - @return: list with description of available video tracks, or NULL on error. + @return: list with description of available video tracks, or None on error. It must be freed with L{libvlc_track_description_list_release}(). ''' f = _Cfunctions.get('libvlc_video_get_track_description', None) or \ _Cfunction('libvlc_video_get_track_description', ((1,),), None, @@ -5354,7 +6054,7 @@ def libvlc_video_take_snapshot(p_mi, num, psz_filepath, i_width, i_height): def libvlc_video_set_deinterlace(p_mi, psz_mode): '''Enable or disable deinterlace filter. @param p_mi: libvlc media player. - @param psz_mode: type of deinterlace filter, NULL to disable. + @param psz_mode: type of deinterlace filter, None to disable. ''' f = _Cfunctions.get('libvlc_video_set_deinterlace', None) or \ _Cfunction('libvlc_video_set_deinterlace', ((1,), (1,),), None, @@ -5494,7 +6194,7 @@ def libvlc_video_set_adjust_float(p_mi, option, value): def libvlc_audio_output_list_get(p_instance): '''Gets the list of available audio output modules. @param p_instance: libvlc instance. - @return: list of available audio outputs. It must be freed it with In case of error, NULL is returned. + @return: list of available audio outputs. It must be freed with In case of error, None is returned. ''' f = _Cfunctions.get('libvlc_audio_output_list_get', None) or \ _Cfunction('libvlc_audio_output_list_get', ((1,),), None, @@ -5527,13 +6227,13 @@ def libvlc_audio_output_device_enum(mp): '''Gets a list of potential audio output devices, See L{libvlc_audio_output_device_set}(). @note: Not all audio outputs support enumerating devices. - The audio output may be functional even if the list is empty (NULL). + The audio output may be functional even if the list is empty (None). @note: The list may not be exhaustive. @warning: Some audio output devices in the list might not actually work in some circumstances. By default, it is recommended to not specify any explicit audio device. @param mp: media player. - @return: A NULL-terminated linked list of potential audio output devices. It must be freed it with L{libvlc_audio_output_device_list_release}(). + @return: A None-terminated linked list of potential audio output devices. It must be freed with L{libvlc_audio_output_device_list_release}(). @version: LibVLC 2.2.0 or later. ''' f = _Cfunctions.get('libvlc_audio_output_device_enum', None) or \ @@ -5544,7 +6244,7 @@ def libvlc_audio_output_device_enum(mp): def libvlc_audio_output_device_list_get(p_instance, aout): '''Gets a list of audio output devices for a given audio output module, See L{libvlc_audio_output_device_set}(). - @note: Not all audio outputs support this. In particular, an empty (NULL) + @note: Not all audio outputs support this. In particular, an empty (None) list of devices does B{not} imply that the specified audio output does not work. @note: The list might not be exhaustive. @@ -5553,7 +6253,7 @@ def libvlc_audio_output_device_list_get(p_instance, aout): explicit audio device. @param p_instance: libvlc instance. @param psz_aout: audio output name (as returned by L{libvlc_audio_output_list_get}()). - @return: A NULL-terminated linked list of potential audio output devices. It must be freed it with L{libvlc_audio_output_device_list_release}(). + @return: A None-terminated linked list of potential audio output devices. It must be freed with L{libvlc_audio_output_device_list_release}(). @version: LibVLC 2.1.0 or later. ''' f = _Cfunctions.get('libvlc_audio_output_device_list_get', None) or \ @@ -5573,15 +6273,15 @@ def libvlc_audio_output_device_list_release(p_list): def libvlc_audio_output_device_set(mp, module, device_id): '''Configures an explicit audio output device. - If the module paramater is NULL, audio output will be moved to the device + If the module paramater is None, audio output will be moved to the device specified by the device identifier string immediately. This is the recommended usage. A list of adequate potential device strings can be obtained with L{libvlc_audio_output_device_enum}(). - However passing NULL is supported in LibVLC version 2.2.0 and later only; + However passing None is supported in LibVLC version 2.2.0 and later only; in earlier versions, this function would have no effects when the module - parameter was NULL. - If the module parameter is not NULL, the device parameter of the + parameter was None. + If the module parameter is not None, the device parameter of the corresponding audio output, if it exists, will be set to the specified string. Note that some audio output modules do not have such a parameter (notably MMDevice and PulseAudio). @@ -5593,7 +6293,7 @@ def libvlc_audio_output_device_set(mp, module, device_id): Some audio output modules require further parameters (e.g. a channels map in the case of ALSA). @param mp: media player. - @param module: If NULL, current audio output module. if non-NULL, name of audio output module. + @param module: If None, current audio output module. if non-None, name of audio output module. @param device_id: device identifier string. @return: Nothing. Errors are ignored (this is a design bug). ''' @@ -5602,6 +6302,27 @@ def libvlc_audio_output_device_set(mp, module, device_id): None, MediaPlayer, ctypes.c_char_p, ctypes.c_char_p) return f(mp, module, device_id) +def libvlc_audio_output_device_get(mp): + '''Get the current audio output device identifier. + This complements L{libvlc_audio_output_device_set}(). + @warning: The initial value for the current audio output device identifier + may not be set or may be some unknown value. A LibVLC application should + compare this value against the known device identifiers (e.g. those that + were previously retrieved by a call to L{libvlc_audio_output_device_enum} or + L{libvlc_audio_output_device_list_get}) to find the current audio output device. + It is possible that the selected audio output device changes (an external + change) without a call to L{libvlc_audio_output_device_set}. That may make this + method unsuitable to use if a LibVLC application is attempting to track + dynamic audio device changes as they happen. + @param mp: media player. + @return: the current audio output device identifier None if no device is selected or in case of error (the result must be released with free() or L{libvlc_free}()). + @version: LibVLC 3.0.0 or later. + ''' + f = _Cfunctions.get('libvlc_audio_output_device_get', None) or \ + _Cfunction('libvlc_audio_output_device_get', ((1,),), None, + ctypes.c_char_p, MediaPlayer) + return f(mp) + def libvlc_audio_toggle_mute(p_mi): '''Toggle mute status. @param p_mi: media player @warning Toggling mute atomically is not always possible: On some platforms, other processes can mute the VLC audio playback stream asynchronously. Thus, there is a small race condition where toggling will not work. See also the limitations of L{libvlc_audio_set_mute}(). @@ -5665,7 +6386,7 @@ def libvlc_audio_get_track_count(p_mi): def libvlc_audio_get_track_description(p_mi): '''Get the description of available audio tracks. @param p_mi: media player. - @return: list with description of available audio tracks, or NULL. + @return: list with description of available audio tracks, or None. It must be freed with L{libvlc_track_description_list_release}(). ''' f = _Cfunctions.get('libvlc_audio_get_track_description', None) or \ _Cfunction('libvlc_audio_get_track_description', ((1,),), None, @@ -5752,7 +6473,7 @@ def libvlc_audio_equalizer_get_preset_name(u_index): This name can be used, for example, to prepare a preset label or menu in a user interface. @param u_index: index of the preset, counting from zero. - @return: preset name, or NULL if there is no such preset. + @return: preset name, or None if there is no such preset. @version: LibVLC 2.2.0 or later. ''' f = _Cfunctions.get('libvlc_audio_equalizer_get_preset_name', None) or \ @@ -5789,7 +6510,7 @@ def libvlc_audio_equalizer_new(): L{libvlc_media_player_set_equalizer}(). The returned handle should be freed via L{libvlc_audio_equalizer_release}() when it is no longer needed. - @return: opaque equalizer handle, or NULL on error. + @return: opaque equalizer handle, or None on error. @version: LibVLC 2.2.0 or later. ''' f = _Cfunctions.get('libvlc_audio_equalizer_new', None) or \ @@ -5805,7 +6526,7 @@ def libvlc_audio_equalizer_new_from_preset(u_index): The returned handle should be freed via L{libvlc_audio_equalizer_release}() when it is no longer needed. @param u_index: index of the preset, counting from zero. - @return: opaque equalizer handle, or NULL on error. + @return: opaque equalizer handle, or None on error. @version: LibVLC 2.2.0 or later. ''' f = _Cfunctions.get('libvlc_audio_equalizer_new_from_preset', None) or \ @@ -5817,8 +6538,8 @@ def libvlc_audio_equalizer_release(p_equalizer): '''Release a previously created equalizer instance. The equalizer was previously created by using L{libvlc_audio_equalizer_new}() or L{libvlc_audio_equalizer_new_from_preset}(). - It is safe to invoke this method with a NULL p_equalizer parameter for no effect. - @param p_equalizer: opaque equalizer handle, or NULL. + It is safe to invoke this method with a None p_equalizer parameter for no effect. + @param p_equalizer: opaque equalizer handle, or None. @version: LibVLC 2.2.0 or later. ''' f = _Cfunctions.get('libvlc_audio_equalizer_release', None) or \ @@ -5831,7 +6552,7 @@ def libvlc_audio_equalizer_set_preamp(p_equalizer, f_preamp): The new equalizer settings are subsequently applied to a media player by invoking L{libvlc_media_player_set_equalizer}(). The supplied amplification value will be clamped to the -20.0 to +20.0 range. - @param p_equalizer: valid equalizer handle, must not be NULL. + @param p_equalizer: valid equalizer handle, must not be None. @param f_preamp: preamp value (-20.0 to 20.0 Hz). @return: zero on success, -1 on error. @version: LibVLC 2.2.0 or later. @@ -5843,7 +6564,7 @@ def libvlc_audio_equalizer_set_preamp(p_equalizer, f_preamp): def libvlc_audio_equalizer_get_preamp(p_equalizer): '''Get the current pre-amplification value from an equalizer. - @param p_equalizer: valid equalizer handle, must not be NULL. + @param p_equalizer: valid equalizer handle, must not be None. @return: preamp value (Hz). @version: LibVLC 2.2.0 or later. ''' @@ -5857,7 +6578,7 @@ def libvlc_audio_equalizer_set_amp_at_index(p_equalizer, f_amp, u_band): The new equalizer settings are subsequently applied to a media player by invoking L{libvlc_media_player_set_equalizer}(). The supplied amplification value will be clamped to the -20.0 to +20.0 range. - @param p_equalizer: valid equalizer handle, must not be NULL. + @param p_equalizer: valid equalizer handle, must not be None. @param f_amp: amplification value (-20.0 to 20.0 Hz). @param u_band: index, counting from zero, of the frequency band to set. @return: zero on success, -1 on error. @@ -5870,7 +6591,7 @@ def libvlc_audio_equalizer_set_amp_at_index(p_equalizer, f_amp, u_band): def libvlc_audio_equalizer_get_amp_at_index(p_equalizer, u_band): '''Get the amplification value for a particular equalizer frequency band. - @param p_equalizer: valid equalizer handle, must not be NULL. + @param p_equalizer: valid equalizer handle, must not be None. @param u_band: index, counting from zero, of the frequency band to get. @return: amplification value (Hz); NaN if there is no such frequency band. @version: LibVLC 2.2.0 or later. @@ -5891,13 +6612,13 @@ def libvlc_media_player_set_equalizer(p_mi, p_equalizer): If there is no currently playing media, the new equalizer settings will be applied later if and when new media is played. Equalizer settings will automatically be applied to subsequently played media. - To disable the equalizer for a media player invoke this method passing NULL for the + To disable the equalizer for a media player invoke this method passing None for the p_equalizer parameter. The media player does not keep a reference to the supplied equalizer so it is safe for an application to release the equalizer reference any time after this method returns. @param p_mi: opaque media player handle. - @param p_equalizer: opaque equalizer handle, or NULL to disable the equalizer for this media player. + @param p_equalizer: opaque equalizer handle, or None to disable the equalizer for this media player. @return: zero on success, -1 on error. @version: LibVLC 2.2.0 or later. ''' @@ -6106,7 +6827,7 @@ def libvlc_vlm_show_media(p_instance, psz_name): vlm_media_t though. @param p_instance: the instance. @param psz_name: the name of the media, if the name is an empty string, all media is described. - @return: string with information about named media, or NULL on error. + @return: string with information about named media, or None on error. ''' f = _Cfunctions.get('libvlc_vlm_show_media', None) or \ _Cfunction('libvlc_vlm_show_media', ((1,), (1,),), string_result, @@ -6218,7 +6939,7 @@ def libvlc_vlm_get_event_manager(p_instance): # libvlc_printerr # libvlc_set_exit_handler -# 28 function(s) not wrapped as methods: +# 31 function(s) not wrapped as methods: # libvlc_audio_equalizer_get_amp_at_index # libvlc_audio_equalizer_get_band_count # libvlc_audio_equalizer_get_band_frequency @@ -6232,6 +6953,7 @@ def libvlc_vlm_get_event_manager(p_instance): # libvlc_audio_equalizer_set_preamp # libvlc_audio_output_device_list_release # libvlc_audio_output_list_release +# libvlc_chapter_descriptions_release # libvlc_clearerr # libvlc_clock # libvlc_errmsg @@ -6242,9 +6964,11 @@ def libvlc_vlm_get_event_manager(p_instance): # libvlc_get_version # libvlc_log_get_context # libvlc_log_get_object +# libvlc_media_get_codec_description # libvlc_media_tracks_release # libvlc_module_description_list_release # libvlc_new +# libvlc_title_descriptions_release # libvlc_track_description_list_release # libvlc_vprinterr diff --git a/openlp/core/ui/media/vlcplayer.py b/openlp/core/ui/media/vlcplayer.py index e8bc1f281..99f8c37fd 100644 --- a/openlp/core/ui/media/vlcplayer.py +++ b/openlp/core/ui/media/vlcplayer.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # @@ -28,7 +28,7 @@ import logging import os import threading import sys - +import ctypes from PyQt5 import QtWidgets from openlp.core.common import Settings, is_win, is_macosx, is_linux @@ -65,14 +65,24 @@ def get_vlc(): if 'openlp.core.ui.media.vendor.vlc' in sys.modules: # If VLC has already been imported, no need to do all the stuff below again return sys.modules['openlp.core.ui.media.vendor.vlc'] - is_vlc_available = False try: if is_macosx(): # Newer versions of VLC on OS X need this. See https://forum.videolan.org/viewtopic.php?t=124521 os.environ['VLC_PLUGIN_PATH'] = '/Applications/VLC.app/Contents/MacOS/plugins' + # On Windows when frozen in PyInstaller, we need to blank SetDllDirectoryW to allow loading of the VLC dll. + # This is due to limitations (by desgin) in PyInstaller. SetDllDirectoryW original value is restored once + # VLC has been imported. + if is_win(): + buffer_size = 1024 + dll_directory = ctypes.create_unicode_buffer(buffer_size) + new_buffer_size = ctypes.windll.kernel32.GetDllDirectoryW(buffer_size, dll_directory) + dll_directory = ''.join(dll_directory[:new_buffer_size]).replace('\0', '') + log.debug('Original DllDirectory: %s' % dll_directory) + ctypes.windll.kernel32.SetDllDirectoryW(None) from openlp.core.ui.media.vendor import vlc - + if is_win(): + ctypes.windll.kernel32.SetDllDirectoryW(dll_directory) is_vlc_available = bool(vlc.get_default_instance()) except (ImportError, NameError, NotImplementedError): pass diff --git a/openlp/core/ui/media/webkitplayer.py b/openlp/core/ui/media/webkitplayer.py index 519d43604..ec17b97ee 100644 --- a/openlp/core/ui/media/webkitplayer.py +++ b/openlp/core/ui/media/webkitplayer.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # diff --git a/openlp/core/ui/mediadockmanager.py b/openlp/core/ui/mediadockmanager.py index 9342fb014..4b8dd71a8 100644 --- a/openlp/core/ui/mediadockmanager.py +++ b/openlp/core/ui/mediadockmanager.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # diff --git a/openlp/core/ui/plugindialog.py b/openlp/core/ui/plugindialog.py index 2c6a7f2c2..5d36dd72c 100644 --- a/openlp/core/ui/plugindialog.py +++ b/openlp/core/ui/plugindialog.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # diff --git a/openlp/core/ui/pluginform.py b/openlp/core/ui/pluginform.py index 4eacebdab..7d71e8ff4 100644 --- a/openlp/core/ui/pluginform.py +++ b/openlp/core/ui/pluginform.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # diff --git a/openlp/core/ui/printservicedialog.py b/openlp/core/ui/printservicedialog.py index 8f22306cf..93a42e2a8 100644 --- a/openlp/core/ui/printservicedialog.py +++ b/openlp/core/ui/printservicedialog.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # diff --git a/openlp/core/ui/printserviceform.py b/openlp/core/ui/printserviceform.py index cfe0d883a..69d8dc606 100644 --- a/openlp/core/ui/printserviceform.py +++ b/openlp/core/ui/printserviceform.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # diff --git a/openlp/core/ui/projector/__init__.py b/openlp/core/ui/projector/__init__.py index d102f9cb6..75d639df3 100644 --- a/openlp/core/ui/projector/__init__.py +++ b/openlp/core/ui/projector/__init__.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # diff --git a/openlp/core/ui/projector/editform.py b/openlp/core/ui/projector/editform.py index df0c57b4c..25c5654cb 100644 --- a/openlp/core/ui/projector/editform.py +++ b/openlp/core/ui/projector/editform.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # diff --git a/openlp/core/ui/projector/manager.py b/openlp/core/ui/projector/manager.py index 46ecfc080..52b640956 100644 --- a/openlp/core/ui/projector/manager.py +++ b/openlp/core/ui/projector/manager.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # diff --git a/openlp/core/ui/projector/sourceselectform.py b/openlp/core/ui/projector/sourceselectform.py index de0cbd2c8..bacf7d093 100644 --- a/openlp/core/ui/projector/sourceselectform.py +++ b/openlp/core/ui/projector/sourceselectform.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # diff --git a/openlp/core/ui/projector/tab.py b/openlp/core/ui/projector/tab.py index 2479e8e63..1b87209c0 100644 --- a/openlp/core/ui/projector/tab.py +++ b/openlp/core/ui/projector/tab.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # diff --git a/openlp/core/ui/serviceitemeditdialog.py b/openlp/core/ui/serviceitemeditdialog.py index 0cfd25446..bbff73f3d 100644 --- a/openlp/core/ui/serviceitemeditdialog.py +++ b/openlp/core/ui/serviceitemeditdialog.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # diff --git a/openlp/core/ui/serviceitemeditform.py b/openlp/core/ui/serviceitemeditform.py index 3e8b140c1..834d1da95 100644 --- a/openlp/core/ui/serviceitemeditform.py +++ b/openlp/core/ui/serviceitemeditform.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index acfde8964..6cb53ab67 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # diff --git a/openlp/core/ui/servicenoteform.py b/openlp/core/ui/servicenoteform.py index 54a09ee25..04da70d15 100644 --- a/openlp/core/ui/servicenoteform.py +++ b/openlp/core/ui/servicenoteform.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # diff --git a/openlp/core/ui/settingsdialog.py b/openlp/core/ui/settingsdialog.py index 566dc70ea..3b6c4bc00 100644 --- a/openlp/core/ui/settingsdialog.py +++ b/openlp/core/ui/settingsdialog.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # diff --git a/openlp/core/ui/settingsform.py b/openlp/core/ui/settingsform.py index 628cd68a8..64f885500 100644 --- a/openlp/core/ui/settingsform.py +++ b/openlp/core/ui/settingsform.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # diff --git a/openlp/core/ui/shortcutlistdialog.py b/openlp/core/ui/shortcutlistdialog.py index 6d9726597..ed1156025 100644 --- a/openlp/core/ui/shortcutlistdialog.py +++ b/openlp/core/ui/shortcutlistdialog.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # @@ -50,6 +50,19 @@ class CaptureShortcutButton(QtWidgets.QPushButton): event.ignore() +class ShortcutTreeWidget(QtWidgets.QTreeWidget): + def __init__(self, *args): + super(ShortcutTreeWidget, self).__init__(*args) + + def keyboardSearch(self, search): + """ + Ignore searches to prevent single letter searches from highlighting items. + + :param search: Search string + """ + pass + + class Ui_ShortcutListDialog(object): """ The UI widgets for the shortcut dialog. @@ -67,7 +80,7 @@ class Ui_ShortcutListDialog(object): self.description_label.setObjectName('description_label') self.description_label.setWordWrap(True) self.shortcut_list_layout.addWidget(self.description_label) - self.tree_widget = QtWidgets.QTreeWidget(shortcutListDialog) + self.tree_widget = ShortcutTreeWidget(shortcutListDialog) self.tree_widget.setObjectName('tree_widget') self.tree_widget.setAlternatingRowColors(True) self.tree_widget.setColumnCount(3) diff --git a/openlp/core/ui/shortcutlistform.py b/openlp/core/ui/shortcutlistform.py index 9780c66f8..81b09fe53 100644 --- a/openlp/core/ui/shortcutlistform.py +++ b/openlp/core/ui/shortcutlistform.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # @@ -96,9 +96,11 @@ class ShortcutListForm(QtWidgets.QDialog, Ui_ShortcutListDialog, RegistryPropert key_sequence = QtGui.QKeySequence(key_string) if self._validiate_shortcut(self._current_item_action(), key_sequence): if self.primary_push_button.isChecked(): - self._adjust_button(self.primary_push_button, False, text=key_sequence.toString()) + self._adjust_button(self.primary_push_button, False, + text=self.get_shortcut_string(key_sequence, for_display=True)) elif self.alternate_push_button.isChecked(): - self._adjust_button(self.alternate_push_button, False, text=key_sequence.toString()) + self._adjust_button(self.alternate_push_button, False, + text=self.get_shortcut_string(key_sequence, for_display=True)) def exec(self): """ @@ -154,11 +156,11 @@ class ShortcutListForm(QtWidgets.QDialog, Ui_ShortcutListDialog, RegistryPropert item.setText(1, '') item.setText(2, '') elif len(shortcuts) == 1: - item.setText(1, shortcuts[0].toString()) + item.setText(1, self.get_shortcut_string(shortcuts[0], for_display=True)) item.setText(2, '') else: - item.setText(1, shortcuts[0].toString()) - item.setText(2, shortcuts[1].toString()) + item.setText(1, self.get_shortcut_string(shortcuts[0], for_display=True)) + item.setText(2, self.get_shortcut_string(shortcuts[1], for_display=True)) self.on_current_item_changed() def on_primary_push_button_clicked(self, toggled): @@ -238,9 +240,9 @@ class ShortcutListForm(QtWidgets.QDialog, Ui_ShortcutListDialog, RegistryPropert self.alternate_push_button.setChecked(False) else: if action.default_shortcuts: - primary_label_text = action.default_shortcuts[0].toString() + primary_label_text = self.get_shortcut_string(action.default_shortcuts[0], for_display=True) if len(action.default_shortcuts) == 2: - alternate_label_text = action.default_shortcuts[1].toString() + alternate_label_text = self.get_shortcut_string(action.default_shortcuts[1], for_display=True) shortcuts = self._action_shortcuts(action) # We do not want to loose pending changes, that is why we have to keep the text when, this function has not # been triggered by a signal. @@ -248,10 +250,10 @@ class ShortcutListForm(QtWidgets.QDialog, Ui_ShortcutListDialog, RegistryPropert primary_text = self.primary_push_button.text() alternate_text = self.alternate_push_button.text() elif len(shortcuts) == 1: - primary_text = shortcuts[0].toString() + primary_text = self.get_shortcut_string(shortcuts[0], for_display=True) elif len(shortcuts) == 2: - primary_text = shortcuts[0].toString() - alternate_text = shortcuts[1].toString() + primary_text = self.get_shortcut_string(shortcuts[0], for_display=True) + alternate_text = self.get_shortcut_string(shortcuts[1], for_display=True) # When we are capturing a new shortcut, we do not want, the buttons to display the current shortcut. if self.primary_push_button.isChecked(): primary_text = '' @@ -305,9 +307,9 @@ class ShortcutListForm(QtWidgets.QDialog, Ui_ShortcutListDialog, RegistryPropert primary_button_text = '' alternate_button_text = '' if temp_shortcuts: - primary_button_text = temp_shortcuts[0].toString() + primary_button_text = self.get_shortcut_string(temp_shortcuts[0], for_display=True) if len(temp_shortcuts) == 2: - alternate_button_text = temp_shortcuts[1].toString() + alternate_button_text = self.get_shortcut_string(temp_shortcuts[1], for_display=True) self.primary_push_button.setText(primary_button_text) self.alternate_push_button.setText(alternate_button_text) @@ -335,7 +337,7 @@ class ShortcutListForm(QtWidgets.QDialog, Ui_ShortcutListDialog, RegistryPropert continue for action in category.actions: if action in self.changed_actions: - old_shortcuts = list(map(QtGui.QKeySequence.toString, action.shortcuts())) + old_shortcuts = list(map(self.get_shortcut_string, action.shortcuts())) action.setShortcuts(self.changed_actions[action]) self.action_list.update_shortcut_map(action, old_shortcuts) settings.setValue(action.objectName(), action.shortcuts()) @@ -418,14 +420,15 @@ class ShortcutListForm(QtWidgets.QDialog, Ui_ShortcutListDialog, RegistryPropert self.main_window.warning_message(translate('OpenLP.ShortcutListDialog', 'Duplicate Shortcut'), translate('OpenLP.ShortcutListDialog', 'The shortcut "%s" is already assigned to another action, please' - ' use a different shortcut.') % key_sequence.toString()) + ' use a different shortcut.') % + self.get_shortcut_string(key_sequence, for_display=True)) self.dialog_was_shown = True return is_valid def _action_shortcuts(self, action): """ This returns the shortcuts for the given ``action``, which also includes those shortcuts which are not saved - yet but already assigned (as changes yre applied when closing the dialog). + yet but already assigned (as changes are applied when closing the dialog). """ if action in self.changed_actions: return self.changed_actions[action] @@ -453,3 +456,14 @@ class ShortcutListForm(QtWidgets.QDialog, Ui_ShortcutListDialog, RegistryPropert button.setChecked(checked) if enabled is not None: button.setEnabled(enabled) + + @staticmethod + def get_shortcut_string(shortcut, for_display=False): + if for_display: + if any(modifier in shortcut.toString() for modifier in ['Ctrl', 'Alt', 'Meta', 'Shift']): + sequence_format = QtGui.QKeySequence.NativeText + else: + sequence_format = QtGui.QKeySequence.PortableText + else: + sequence_format = QtGui.QKeySequence.PortableText + return shortcut.toString(sequence_format) diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index dce623809..f93c52c06 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # diff --git a/openlp/core/ui/splashscreen.py b/openlp/core/ui/splashscreen.py index f67a8150d..adfa3ec4a 100644 --- a/openlp/core/ui/splashscreen.py +++ b/openlp/core/ui/splashscreen.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # diff --git a/openlp/core/ui/starttimedialog.py b/openlp/core/ui/starttimedialog.py index 9313b953c..42287596c 100644 --- a/openlp/core/ui/starttimedialog.py +++ b/openlp/core/ui/starttimedialog.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # diff --git a/openlp/core/ui/starttimeform.py b/openlp/core/ui/starttimeform.py index c37c4dacf..16e582ff5 100644 --- a/openlp/core/ui/starttimeform.py +++ b/openlp/core/ui/starttimeform.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # diff --git a/openlp/core/ui/themeform.py b/openlp/core/ui/themeform.py index 81755e261..3a652cebc 100644 --- a/openlp/core/ui/themeform.py +++ b/openlp/core/ui/themeform.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # diff --git a/openlp/core/ui/themelayoutdialog.py b/openlp/core/ui/themelayoutdialog.py index f6acf462e..5289e1cc2 100644 --- a/openlp/core/ui/themelayoutdialog.py +++ b/openlp/core/ui/themelayoutdialog.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # diff --git a/openlp/core/ui/themelayoutform.py b/openlp/core/ui/themelayoutform.py index c28987524..6fc01a6a5 100644 --- a/openlp/core/ui/themelayoutform.py +++ b/openlp/core/ui/themelayoutform.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # diff --git a/openlp/core/ui/thememanager.py b/openlp/core/ui/thememanager.py index 1115b95fc..fdf87e528 100644 --- a/openlp/core/ui/thememanager.py +++ b/openlp/core/ui/thememanager.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # diff --git a/openlp/core/ui/themestab.py b/openlp/core/ui/themestab.py index 7c3a45f23..a953ae013 100644 --- a/openlp/core/ui/themestab.py +++ b/openlp/core/ui/themestab.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # diff --git a/openlp/core/ui/themewizard.py b/openlp/core/ui/themewizard.py index 5b60a6567..b041a0905 100644 --- a/openlp/core/ui/themewizard.py +++ b/openlp/core/ui/themewizard.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # diff --git a/openlp/core/ui/wizard.py b/openlp/core/ui/wizard.py index 738ca3d27..9399616a8 100644 --- a/openlp/core/ui/wizard.py +++ b/openlp/core/ui/wizard.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # diff --git a/openlp/core/utils/__init__.py b/openlp/core/utils/__init__.py index 75f84b8f8..086c69c79 100644 --- a/openlp/core/utils/__init__.py +++ b/openlp/core/utils/__init__.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # diff --git a/openlp/core/utils/actions.py b/openlp/core/utils/actions.py index 3d0afa2be..cb5b9ccaf 100644 --- a/openlp/core/utils/actions.py +++ b/openlp/core/utils/actions.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # diff --git a/openlp/core/utils/languagemanager.py b/openlp/core/utils/languagemanager.py index f2937a9fa..873b64c57 100644 --- a/openlp/core/utils/languagemanager.py +++ b/openlp/core/utils/languagemanager.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # diff --git a/openlp/plugins/__init__.py b/openlp/plugins/__init__.py index 60e01971b..6de0f581a 100644 --- a/openlp/plugins/__init__.py +++ b/openlp/plugins/__init__.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # diff --git a/openlp/plugins/alerts/__init__.py b/openlp/plugins/alerts/__init__.py index 185dee791..9e56dbc1f 100644 --- a/openlp/plugins/alerts/__init__.py +++ b/openlp/plugins/alerts/__init__.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # diff --git a/openlp/plugins/alerts/alertsplugin.py b/openlp/plugins/alerts/alertsplugin.py index e41b34d4d..9e1f44613 100644 --- a/openlp/plugins/alerts/alertsplugin.py +++ b/openlp/plugins/alerts/alertsplugin.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # diff --git a/openlp/plugins/alerts/forms/__init__.py b/openlp/plugins/alerts/forms/__init__.py index ad44a5389..168ccfff8 100644 --- a/openlp/plugins/alerts/forms/__init__.py +++ b/openlp/plugins/alerts/forms/__init__.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # diff --git a/openlp/plugins/alerts/forms/alertdialog.py b/openlp/plugins/alerts/forms/alertdialog.py index f9827eb6e..81af23ae1 100644 --- a/openlp/plugins/alerts/forms/alertdialog.py +++ b/openlp/plugins/alerts/forms/alertdialog.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # diff --git a/openlp/plugins/alerts/forms/alertform.py b/openlp/plugins/alerts/forms/alertform.py index 8656ef193..1c66119c5 100644 --- a/openlp/plugins/alerts/forms/alertform.py +++ b/openlp/plugins/alerts/forms/alertform.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # diff --git a/openlp/plugins/alerts/lib/__init__.py b/openlp/plugins/alerts/lib/__init__.py index 8aa2989f7..4e353a786 100644 --- a/openlp/plugins/alerts/lib/__init__.py +++ b/openlp/plugins/alerts/lib/__init__.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # diff --git a/openlp/plugins/alerts/lib/alertsmanager.py b/openlp/plugins/alerts/lib/alertsmanager.py index 94abbaff5..fd9fbaf09 100644 --- a/openlp/plugins/alerts/lib/alertsmanager.py +++ b/openlp/plugins/alerts/lib/alertsmanager.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # diff --git a/openlp/plugins/alerts/lib/alertstab.py b/openlp/plugins/alerts/lib/alertstab.py index bae2e8c89..2875493b6 100644 --- a/openlp/plugins/alerts/lib/alertstab.py +++ b/openlp/plugins/alerts/lib/alertstab.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # diff --git a/openlp/plugins/alerts/lib/db.py b/openlp/plugins/alerts/lib/db.py index f9cddb56b..34eb4a940 100644 --- a/openlp/plugins/alerts/lib/db.py +++ b/openlp/plugins/alerts/lib/db.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # diff --git a/openlp/plugins/bibles/__init__.py b/openlp/plugins/bibles/__init__.py index 011cd2b2a..a9ce1a4cf 100644 --- a/openlp/plugins/bibles/__init__.py +++ b/openlp/plugins/bibles/__init__.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # diff --git a/openlp/plugins/bibles/bibleplugin.py b/openlp/plugins/bibles/bibleplugin.py index cd4fada7a..022790c58 100644 --- a/openlp/plugins/bibles/bibleplugin.py +++ b/openlp/plugins/bibles/bibleplugin.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # diff --git a/openlp/plugins/bibles/forms/__init__.py b/openlp/plugins/bibles/forms/__init__.py index f5e770815..145a8a2fa 100644 --- a/openlp/plugins/bibles/forms/__init__.py +++ b/openlp/plugins/bibles/forms/__init__.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # diff --git a/openlp/plugins/bibles/forms/bibleimportform.py b/openlp/plugins/bibles/forms/bibleimportform.py index 8bb71a15f..61f8733b8 100644 --- a/openlp/plugins/bibles/forms/bibleimportform.py +++ b/openlp/plugins/bibles/forms/bibleimportform.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # diff --git a/openlp/plugins/bibles/forms/bibleupgradeform.py b/openlp/plugins/bibles/forms/bibleupgradeform.py index fc7d9df33..4adfeaf3b 100644 --- a/openlp/plugins/bibles/forms/bibleupgradeform.py +++ b/openlp/plugins/bibles/forms/bibleupgradeform.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # diff --git a/openlp/plugins/bibles/forms/booknamedialog.py b/openlp/plugins/bibles/forms/booknamedialog.py index b83e6b9c2..6679dc1f3 100644 --- a/openlp/plugins/bibles/forms/booknamedialog.py +++ b/openlp/plugins/bibles/forms/booknamedialog.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # diff --git a/openlp/plugins/bibles/forms/booknameform.py b/openlp/plugins/bibles/forms/booknameform.py index 2fe79510b..9fa117083 100644 --- a/openlp/plugins/bibles/forms/booknameform.py +++ b/openlp/plugins/bibles/forms/booknameform.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # diff --git a/openlp/plugins/bibles/forms/editbibledialog.py b/openlp/plugins/bibles/forms/editbibledialog.py index 894eddb84..978f019ad 100644 --- a/openlp/plugins/bibles/forms/editbibledialog.py +++ b/openlp/plugins/bibles/forms/editbibledialog.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # diff --git a/openlp/plugins/bibles/forms/editbibleform.py b/openlp/plugins/bibles/forms/editbibleform.py index 64399dc2d..0a96b1a0e 100644 --- a/openlp/plugins/bibles/forms/editbibleform.py +++ b/openlp/plugins/bibles/forms/editbibleform.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # diff --git a/openlp/plugins/bibles/forms/languagedialog.py b/openlp/plugins/bibles/forms/languagedialog.py index 2dc0566f7..ea5c291a0 100644 --- a/openlp/plugins/bibles/forms/languagedialog.py +++ b/openlp/plugins/bibles/forms/languagedialog.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # diff --git a/openlp/plugins/bibles/forms/languageform.py b/openlp/plugins/bibles/forms/languageform.py index f0e270a4a..91d1d074d 100644 --- a/openlp/plugins/bibles/forms/languageform.py +++ b/openlp/plugins/bibles/forms/languageform.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # diff --git a/openlp/plugins/bibles/lib/__init__.py b/openlp/plugins/bibles/lib/__init__.py index df72514fa..0bba1e387 100644 --- a/openlp/plugins/bibles/lib/__init__.py +++ b/openlp/plugins/bibles/lib/__init__.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # diff --git a/openlp/plugins/bibles/lib/biblestab.py b/openlp/plugins/bibles/lib/biblestab.py index f32bf6146..5438d07f2 100644 --- a/openlp/plugins/bibles/lib/biblestab.py +++ b/openlp/plugins/bibles/lib/biblestab.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # diff --git a/openlp/plugins/bibles/lib/csvbible.py b/openlp/plugins/bibles/lib/csvbible.py index 0836acaab..2e95697e3 100644 --- a/openlp/plugins/bibles/lib/csvbible.py +++ b/openlp/plugins/bibles/lib/csvbible.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # diff --git a/openlp/plugins/bibles/lib/db.py b/openlp/plugins/bibles/lib/db.py index a749ca2c3..b77117e21 100644 --- a/openlp/plugins/bibles/lib/db.py +++ b/openlp/plugins/bibles/lib/db.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # diff --git a/openlp/plugins/bibles/lib/http.py b/openlp/plugins/bibles/lib/http.py index fcf4b049d..05f197422 100644 --- a/openlp/plugins/bibles/lib/http.py +++ b/openlp/plugins/bibles/lib/http.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # diff --git a/openlp/plugins/bibles/lib/manager.py b/openlp/plugins/bibles/lib/manager.py index 68e6c2d57..3d1c5b2bf 100644 --- a/openlp/plugins/bibles/lib/manager.py +++ b/openlp/plugins/bibles/lib/manager.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index 98a0175f2..3934ca53c 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # diff --git a/openlp/plugins/bibles/lib/opensong.py b/openlp/plugins/bibles/lib/opensong.py index 8e3716435..b2836dcd4 100644 --- a/openlp/plugins/bibles/lib/opensong.py +++ b/openlp/plugins/bibles/lib/opensong.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # diff --git a/openlp/plugins/bibles/lib/osis.py b/openlp/plugins/bibles/lib/osis.py index 12b2f2494..acba710c1 100644 --- a/openlp/plugins/bibles/lib/osis.py +++ b/openlp/plugins/bibles/lib/osis.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # diff --git a/openlp/plugins/bibles/lib/upgrade.py b/openlp/plugins/bibles/lib/upgrade.py index 63bb1c27f..7cc58ef7b 100644 --- a/openlp/plugins/bibles/lib/upgrade.py +++ b/openlp/plugins/bibles/lib/upgrade.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # diff --git a/openlp/plugins/bibles/lib/versereferencelist.py b/openlp/plugins/bibles/lib/versereferencelist.py index 38496d956..a7f143b21 100644 --- a/openlp/plugins/bibles/lib/versereferencelist.py +++ b/openlp/plugins/bibles/lib/versereferencelist.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # diff --git a/openlp/plugins/bibles/lib/zefania.py b/openlp/plugins/bibles/lib/zefania.py index 1f79dcfd9..6e9f0b956 100644 --- a/openlp/plugins/bibles/lib/zefania.py +++ b/openlp/plugins/bibles/lib/zefania.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # diff --git a/openlp/plugins/custom/__init__.py b/openlp/plugins/custom/__init__.py index 3c5e58a1b..958c70ad3 100644 --- a/openlp/plugins/custom/__init__.py +++ b/openlp/plugins/custom/__init__.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # diff --git a/openlp/plugins/custom/customplugin.py b/openlp/plugins/custom/customplugin.py index 4f0741266..c5412199d 100644 --- a/openlp/plugins/custom/customplugin.py +++ b/openlp/plugins/custom/customplugin.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # diff --git a/openlp/plugins/custom/forms/__init__.py b/openlp/plugins/custom/forms/__init__.py index c9e117b57..02bded5b0 100644 --- a/openlp/plugins/custom/forms/__init__.py +++ b/openlp/plugins/custom/forms/__init__.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # diff --git a/openlp/plugins/custom/forms/editcustomdialog.py b/openlp/plugins/custom/forms/editcustomdialog.py index 16bb1413b..b686e5522 100644 --- a/openlp/plugins/custom/forms/editcustomdialog.py +++ b/openlp/plugins/custom/forms/editcustomdialog.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # diff --git a/openlp/plugins/custom/forms/editcustomform.py b/openlp/plugins/custom/forms/editcustomform.py index 42dad7410..6d7731dd6 100644 --- a/openlp/plugins/custom/forms/editcustomform.py +++ b/openlp/plugins/custom/forms/editcustomform.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # diff --git a/openlp/plugins/custom/forms/editcustomslidedialog.py b/openlp/plugins/custom/forms/editcustomslidedialog.py index 22e5f4209..c5212c84e 100644 --- a/openlp/plugins/custom/forms/editcustomslidedialog.py +++ b/openlp/plugins/custom/forms/editcustomslidedialog.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # diff --git a/openlp/plugins/custom/forms/editcustomslideform.py b/openlp/plugins/custom/forms/editcustomslideform.py index fb4ba3535..9de3875bd 100644 --- a/openlp/plugins/custom/forms/editcustomslideform.py +++ b/openlp/plugins/custom/forms/editcustomslideform.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # diff --git a/openlp/plugins/custom/lib/__init__.py b/openlp/plugins/custom/lib/__init__.py index 943f959aa..ea719915a 100644 --- a/openlp/plugins/custom/lib/__init__.py +++ b/openlp/plugins/custom/lib/__init__.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # diff --git a/openlp/plugins/custom/lib/customtab.py b/openlp/plugins/custom/lib/customtab.py index 5f886e783..8350e1c06 100644 --- a/openlp/plugins/custom/lib/customtab.py +++ b/openlp/plugins/custom/lib/customtab.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # diff --git a/openlp/plugins/custom/lib/customxmlhandler.py b/openlp/plugins/custom/lib/customxmlhandler.py index d01c278dc..7ae04d123 100644 --- a/openlp/plugins/custom/lib/customxmlhandler.py +++ b/openlp/plugins/custom/lib/customxmlhandler.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # diff --git a/openlp/plugins/custom/lib/db.py b/openlp/plugins/custom/lib/db.py index 2db0a8958..743822072 100644 --- a/openlp/plugins/custom/lib/db.py +++ b/openlp/plugins/custom/lib/db.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # diff --git a/openlp/plugins/custom/lib/mediaitem.py b/openlp/plugins/custom/lib/mediaitem.py index 08d8bc2c1..812274263 100644 --- a/openlp/plugins/custom/lib/mediaitem.py +++ b/openlp/plugins/custom/lib/mediaitem.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # diff --git a/openlp/plugins/images/__init__.py b/openlp/plugins/images/__init__.py index 28eff64f1..8af64695d 100644 --- a/openlp/plugins/images/__init__.py +++ b/openlp/plugins/images/__init__.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # diff --git a/openlp/plugins/images/forms/__init__.py b/openlp/plugins/images/forms/__init__.py index 17a07fcc6..04a893461 100644 --- a/openlp/plugins/images/forms/__init__.py +++ b/openlp/plugins/images/forms/__init__.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # diff --git a/openlp/plugins/images/forms/addgroupdialog.py b/openlp/plugins/images/forms/addgroupdialog.py index b34cb177e..7f69fc3e0 100644 --- a/openlp/plugins/images/forms/addgroupdialog.py +++ b/openlp/plugins/images/forms/addgroupdialog.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # diff --git a/openlp/plugins/images/forms/addgroupform.py b/openlp/plugins/images/forms/addgroupform.py index 6dc5c51d3..e0021c8a5 100644 --- a/openlp/plugins/images/forms/addgroupform.py +++ b/openlp/plugins/images/forms/addgroupform.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # diff --git a/openlp/plugins/images/forms/choosegroupdialog.py b/openlp/plugins/images/forms/choosegroupdialog.py index c3a92a6ea..2d67fbcd2 100644 --- a/openlp/plugins/images/forms/choosegroupdialog.py +++ b/openlp/plugins/images/forms/choosegroupdialog.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # diff --git a/openlp/plugins/images/forms/choosegroupform.py b/openlp/plugins/images/forms/choosegroupform.py index 6ab560bf4..ad699afcd 100644 --- a/openlp/plugins/images/forms/choosegroupform.py +++ b/openlp/plugins/images/forms/choosegroupform.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # diff --git a/openlp/plugins/images/imageplugin.py b/openlp/plugins/images/imageplugin.py index 9d4b82254..4ec0f9c2b 100644 --- a/openlp/plugins/images/imageplugin.py +++ b/openlp/plugins/images/imageplugin.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # diff --git a/openlp/plugins/images/lib/__init__.py b/openlp/plugins/images/lib/__init__.py index 342a206e7..da9c44c6d 100644 --- a/openlp/plugins/images/lib/__init__.py +++ b/openlp/plugins/images/lib/__init__.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # diff --git a/openlp/plugins/images/lib/db.py b/openlp/plugins/images/lib/db.py index 196418c16..eaa049156 100644 --- a/openlp/plugins/images/lib/db.py +++ b/openlp/plugins/images/lib/db.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # diff --git a/openlp/plugins/images/lib/imagetab.py b/openlp/plugins/images/lib/imagetab.py index 00e7fef0a..80578dc56 100644 --- a/openlp/plugins/images/lib/imagetab.py +++ b/openlp/plugins/images/lib/imagetab.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # diff --git a/openlp/plugins/images/lib/mediaitem.py b/openlp/plugins/images/lib/mediaitem.py index 96c2c6cc5..248da94ea 100644 --- a/openlp/plugins/images/lib/mediaitem.py +++ b/openlp/plugins/images/lib/mediaitem.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # diff --git a/openlp/plugins/media/__init__.py b/openlp/plugins/media/__init__.py index 8529d7e85..b3fab35d3 100644 --- a/openlp/plugins/media/__init__.py +++ b/openlp/plugins/media/__init__.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # diff --git a/openlp/plugins/media/forms/__init__.py b/openlp/plugins/media/forms/__init__.py index c9e117b57..02bded5b0 100644 --- a/openlp/plugins/media/forms/__init__.py +++ b/openlp/plugins/media/forms/__init__.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # diff --git a/openlp/plugins/media/forms/mediaclipselectordialog.py b/openlp/plugins/media/forms/mediaclipselectordialog.py index 2b1276b6f..5fd969f66 100644 --- a/openlp/plugins/media/forms/mediaclipselectordialog.py +++ b/openlp/plugins/media/forms/mediaclipselectordialog.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # diff --git a/openlp/plugins/media/forms/mediaclipselectorform.py b/openlp/plugins/media/forms/mediaclipselectorform.py index 1d6fede42..f94129198 100644 --- a/openlp/plugins/media/forms/mediaclipselectorform.py +++ b/openlp/plugins/media/forms/mediaclipselectorform.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # @@ -31,6 +31,7 @@ from PyQt5 import QtCore, QtGui, QtWidgets from openlp.core.common import translate, is_win, is_linux, is_macosx, RegistryProperties from openlp.plugins.media.forms.mediaclipselectordialog import Ui_MediaClipSelector from openlp.core.lib.ui import critical_error_message_box +from openlp.core.ui.media.vlcplayer import get_vlc if is_win(): from win32com.client import Dispatch @@ -38,17 +39,6 @@ if is_win(): if is_linux(): import dbus -try: - from openlp.core.ui.media.vendor import vlc -except (ImportError, NameError, NotImplementedError): - pass -except OSError as e: - if is_win(): - if not isinstance(e, WindowsError) and e.winerror != 126: - raise - else: - raise - log = logging.getLogger(__name__) @@ -126,6 +116,7 @@ class MediaClipSelectorForm(QtWidgets.QDialog, Ui_MediaClipSelector, RegistryPro """ Setup VLC instance and mediaplayer """ + vlc = get_vlc() self.vlc_instance = vlc.Instance() # creating an empty vlc media player self.vlc_media_player = self.vlc_instance.media_player_new() @@ -160,6 +151,7 @@ class MediaClipSelectorForm(QtWidgets.QDialog, Ui_MediaClipSelector, RegistryPro :param path: Path to the device to be tested. :return: True if it was an audio CD else False. """ + vlc = get_vlc() # Detect by trying to play it as a CD self.vlc_media = self.vlc_instance.media_new_location('cdda://' + path) self.vlc_media_player.set_media(self.vlc_media) @@ -193,6 +185,7 @@ class MediaClipSelectorForm(QtWidgets.QDialog, Ui_MediaClipSelector, RegistryPro :param clicked: Given from signal, not used. """ log.debug('on_load_disc_button_clicked') + vlc = get_vlc() self.disable_all() self.application.set_busy_cursor() path = self.media_path_combobox.currentText() @@ -281,6 +274,7 @@ class MediaClipSelectorForm(QtWidgets.QDialog, Ui_MediaClipSelector, RegistryPro :param clicked: Given from signal, not used. """ + vlc = get_vlc() if self.vlc_media_player.get_state() == vlc.State.Playing: self.vlc_media_player.pause() self.play_button.setIcon(self.play_icon) @@ -381,6 +375,7 @@ class MediaClipSelectorForm(QtWidgets.QDialog, Ui_MediaClipSelector, RegistryPro :param index: The index of the newly chosen title track. """ log.debug('in on_titles_combo_box_changed, index: %d', index) + vlc = get_vlc() if not self.vlc_media_player: log.error('vlc_media_player was None') return @@ -619,6 +614,7 @@ class MediaClipSelectorForm(QtWidgets.QDialog, Ui_MediaClipSelector, RegistryPro :param media_state: VLC media state to wait for. :return: True if state was reached within 15 seconds, False if not or error occurred. """ + vlc = get_vlc() start = datetime.now() while media_state != self.vlc_media_player.get_state(): if self.vlc_media_player.get_state() == vlc.State.Error: diff --git a/openlp/plugins/media/lib/__init__.py b/openlp/plugins/media/lib/__init__.py index b9b4311cd..de455862a 100644 --- a/openlp/plugins/media/lib/__init__.py +++ b/openlp/plugins/media/lib/__init__.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # diff --git a/openlp/plugins/media/lib/mediaitem.py b/openlp/plugins/media/lib/mediaitem.py index 21af839aa..09b32b308 100644 --- a/openlp/plugins/media/lib/mediaitem.py +++ b/openlp/plugins/media/lib/mediaitem.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # diff --git a/openlp/plugins/media/lib/mediatab.py b/openlp/plugins/media/lib/mediatab.py index 0b51aebf9..5b8fb7c2f 100644 --- a/openlp/plugins/media/lib/mediatab.py +++ b/openlp/plugins/media/lib/mediatab.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # diff --git a/openlp/plugins/media/mediaplugin.py b/openlp/plugins/media/mediaplugin.py index a1688ab7e..8c83acfef 100644 --- a/openlp/plugins/media/mediaplugin.py +++ b/openlp/plugins/media/mediaplugin.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # diff --git a/openlp/plugins/presentations/__init__.py b/openlp/plugins/presentations/__init__.py index dae038e06..f3b812dd8 100644 --- a/openlp/plugins/presentations/__init__.py +++ b/openlp/plugins/presentations/__init__.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # diff --git a/openlp/plugins/presentations/lib/__init__.py b/openlp/plugins/presentations/lib/__init__.py index 73489abf0..e357c1ad8 100644 --- a/openlp/plugins/presentations/lib/__init__.py +++ b/openlp/plugins/presentations/lib/__init__.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # diff --git a/openlp/plugins/presentations/lib/impresscontroller.py b/openlp/plugins/presentations/lib/impresscontroller.py index 5ac48dded..183a05ac5 100644 --- a/openlp/plugins/presentations/lib/impresscontroller.py +++ b/openlp/plugins/presentations/lib/impresscontroller.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # diff --git a/openlp/plugins/presentations/lib/mediaitem.py b/openlp/plugins/presentations/lib/mediaitem.py index c99bc3ba2..b2ece3e67 100644 --- a/openlp/plugins/presentations/lib/mediaitem.py +++ b/openlp/plugins/presentations/lib/mediaitem.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # diff --git a/openlp/plugins/presentations/lib/messagelistener.py b/openlp/plugins/presentations/lib/messagelistener.py index 8179cb2e7..0f33abeb9 100644 --- a/openlp/plugins/presentations/lib/messagelistener.py +++ b/openlp/plugins/presentations/lib/messagelistener.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # diff --git a/openlp/plugins/presentations/lib/pdfcontroller.py b/openlp/plugins/presentations/lib/pdfcontroller.py index c16c54205..64e197eba 100644 --- a/openlp/plugins/presentations/lib/pdfcontroller.py +++ b/openlp/plugins/presentations/lib/pdfcontroller.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # diff --git a/openlp/plugins/presentations/lib/powerpointcontroller.py b/openlp/plugins/presentations/lib/powerpointcontroller.py index 138d095bc..6cc6a8450 100644 --- a/openlp/plugins/presentations/lib/powerpointcontroller.py +++ b/openlp/plugins/presentations/lib/powerpointcontroller.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # diff --git a/openlp/plugins/presentations/lib/pptviewcontroller.py b/openlp/plugins/presentations/lib/pptviewcontroller.py index fee83c9de..aba0aa88e 100644 --- a/openlp/plugins/presentations/lib/pptviewcontroller.py +++ b/openlp/plugins/presentations/lib/pptviewcontroller.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # diff --git a/openlp/plugins/presentations/lib/pptviewlib/README.TXT b/openlp/plugins/presentations/lib/pptviewlib/README.TXT index bec5db4eb..1c5fe5d28 100644 --- a/openlp/plugins/presentations/lib/pptviewlib/README.TXT +++ b/openlp/plugins/presentations/lib/pptviewlib/README.TXT @@ -1,6 +1,6 @@ PPTVIEWLIB - Control PowerPoint Viewer 2003/2007 (for openlp.org) -Copyright (C) 2008-2015 Jonathan Corwin (j@corwin.co.uk) +Copyright (C) 2008-2016 Jonathan Corwin (j@corwin.co.uk) This library wrappers the free Microsoft PowerPoint Viewer (2003/2007) program, allowing it to be more easily controlled from another program. diff --git a/openlp/plugins/presentations/lib/pptviewlib/ppttest.py b/openlp/plugins/presentations/lib/pptviewlib/ppttest.py index f3685940c..3d777b9e7 100644 --- a/openlp/plugins/presentations/lib/pptviewlib/ppttest.py +++ b/openlp/plugins/presentations/lib/pptviewlib/ppttest.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # diff --git a/openlp/plugins/presentations/lib/pptviewlib/pptviewlib.cpp b/openlp/plugins/presentations/lib/pptviewlib/pptviewlib.cpp index d60566575..22b46f760 100644 --- a/openlp/plugins/presentations/lib/pptviewlib/pptviewlib.cpp +++ b/openlp/plugins/presentations/lib/pptviewlib/pptviewlib.cpp @@ -1,7 +1,7 @@ /****************************************************************************** * OpenLP - Open Source Lyrics Projection * * --------------------------------------------------------------------------- * -* Copyright (c) 2008-2015 OpenLP Developers * +* Copyright (c) 2008-2016 OpenLP Developers * * --------------------------------------------------------------------------- * * This program is free software; you can redistribute it and/or modify it * * under the terms of the GNU General Public License as published by the Free * diff --git a/openlp/plugins/presentations/lib/pptviewlib/pptviewlib.h b/openlp/plugins/presentations/lib/pptviewlib/pptviewlib.h index dd7a98f5d..e54c95537 100644 --- a/openlp/plugins/presentations/lib/pptviewlib/pptviewlib.h +++ b/openlp/plugins/presentations/lib/pptviewlib/pptviewlib.h @@ -1,7 +1,7 @@ /****************************************************************************** * OpenLP - Open Source Lyrics Projection * * --------------------------------------------------------------------------- * -* Copyright (c) 2008-2015 OpenLP Developers * +* Copyright (c) 2008-2016 OpenLP Developers * * --------------------------------------------------------------------------- * * This program is free software; you can redistribute it and/or modify it * * under the terms of the GNU General Public License as published by the Free * diff --git a/openlp/plugins/presentations/lib/presentationcontroller.py b/openlp/plugins/presentations/lib/presentationcontroller.py index e9ada675e..abc71f867 100644 --- a/openlp/plugins/presentations/lib/presentationcontroller.py +++ b/openlp/plugins/presentations/lib/presentationcontroller.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # diff --git a/openlp/plugins/presentations/lib/presentationtab.py b/openlp/plugins/presentations/lib/presentationtab.py index 28e7ccf6d..cbe881853 100644 --- a/openlp/plugins/presentations/lib/presentationtab.py +++ b/openlp/plugins/presentations/lib/presentationtab.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # diff --git a/openlp/plugins/presentations/presentationplugin.py b/openlp/plugins/presentations/presentationplugin.py index 5e94645d9..0d5dde029 100644 --- a/openlp/plugins/presentations/presentationplugin.py +++ b/openlp/plugins/presentations/presentationplugin.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # diff --git a/openlp/plugins/remotes/__init__.py b/openlp/plugins/remotes/__init__.py index 67cb76cb1..c64704074 100644 --- a/openlp/plugins/remotes/__init__.py +++ b/openlp/plugins/remotes/__init__.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # diff --git a/openlp/plugins/remotes/html/index.html b/openlp/plugins/remotes/html/index.html index edb2e6551..eb5ec2ff9 100644 --- a/openlp/plugins/remotes/html/index.html +++ b/openlp/plugins/remotes/html/index.html @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2016 OpenLP Developers # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # diff --git a/openlp/plugins/remotes/html/jquery.js b/openlp/plugins/remotes/html/jquery.js new file mode 100644 index 000000000..3774ff986 --- /dev/null +++ b/openlp/plugins/remotes/html/jquery.js @@ -0,0 +1,9404 @@ +/*! + * jQuery JavaScript Library v1.7.2 + * http://jquery.com/ + * + * Copyright 2011, John Resig + * Dual licensed under the MIT or GPL Version 2 licenses. + * http://jquery.org/license + * + * Includes Sizzle.js + * http://sizzlejs.com/ + * Copyright 2011, The Dojo Foundation + * Released under the MIT, BSD, and GPL Licenses. + * + * Date: Wed Mar 21 12:46:34 2012 -0700 + */ +(function( window, undefined ) { + +// Use the correct document accordingly with window argument (sandbox) +var document = window.document, + navigator = window.navigator, + location = window.location; +var jQuery = (function() { + +// Define a local copy of jQuery +var jQuery = function( selector, context ) { + // The jQuery object is actually just the init constructor 'enhanced' + return new jQuery.fn.init( selector, context, rootjQuery ); + }, + + // Map over jQuery in case of overwrite + _jQuery = window.jQuery, + + // Map over the $ in case of overwrite + _$ = window.$, + + // A central reference to the root jQuery(document) + rootjQuery, + + // A simple way to check for HTML strings or ID strings + // Prioritize #id over to avoid XSS via location.hash (#9521) + quickExpr = /^(?:[^#<]*(<[\w\W]+>)[^>]*$|#([\w\-]*)$)/, + + // Check if a string has a non-whitespace character in it + rnotwhite = /\S/, + + // Used for trimming whitespace + trimLeft = /^\s+/, + trimRight = /\s+$/, + + // Match a standalone tag + rsingleTag = /^<(\w+)\s*\/?>(?:<\/\1>)?$/, + + // JSON RegExp + rvalidchars = /^[\],:{}\s]*$/, + rvalidescape = /\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, + rvalidtokens = /"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, + rvalidbraces = /(?:^|:|,)(?:\s*\[)+/g, + + // Useragent RegExp + rwebkit = /(webkit)[ \/]([\w.]+)/, + ropera = /(opera)(?:.*version)?[ \/]([\w.]+)/, + rmsie = /(msie) ([\w.]+)/, + rmozilla = /(mozilla)(?:.*? rv:([\w.]+))?/, + + // Matches dashed string for camelizing + rdashAlpha = /-([a-z]|[0-9])/ig, + rmsPrefix = /^-ms-/, + + // Used by jQuery.camelCase as callback to replace() + fcamelCase = function( all, letter ) { + return ( letter + "" ).toUpperCase(); + }, + + // Keep a UserAgent string for use with jQuery.browser + userAgent = navigator.userAgent, + + // For matching the engine and version of the browser + browserMatch, + + // The deferred used on DOM ready + readyList, + + // The ready event handler + DOMContentLoaded, + + // Save a reference to some core methods + toString = Object.prototype.toString, + hasOwn = Object.prototype.hasOwnProperty, + push = Array.prototype.push, + slice = Array.prototype.slice, + trim = String.prototype.trim, + indexOf = Array.prototype.indexOf, + + // [[Class]] -> type pairs + class2type = {}; + +jQuery.fn = jQuery.prototype = { + constructor: jQuery, + init: function( selector, context, rootjQuery ) { + var match, elem, ret, doc; + + // Handle $(""), $(null), or $(undefined) + if ( !selector ) { + return this; + } + + // Handle $(DOMElement) + if ( selector.nodeType ) { + this.context = this[0] = selector; + this.length = 1; + return this; + } + + // The body element only exists once, optimize finding it + if ( selector === "body" && !context && document.body ) { + this.context = document; + this[0] = document.body; + this.selector = selector; + this.length = 1; + return this; + } + + // Handle HTML strings + if ( typeof selector === "string" ) { + // Are we dealing with HTML string or an ID? + if ( selector.charAt(0) === "<" && selector.charAt( selector.length - 1 ) === ">" && selector.length >= 3 ) { + // Assume that strings that start and end with <> are HTML and skip the regex check + match = [ null, selector, null ]; + + } else { + match = quickExpr.exec( selector ); + } + + // Verify a match, and that no context was specified for #id + if ( match && (match[1] || !context) ) { + + // HANDLE: $(html) -> $(array) + if ( match[1] ) { + context = context instanceof jQuery ? context[0] : context; + doc = ( context ? context.ownerDocument || context : document ); + + // If a single string is passed in and it's a single tag + // just do a createElement and skip the rest + ret = rsingleTag.exec( selector ); + + if ( ret ) { + if ( jQuery.isPlainObject( context ) ) { + selector = [ document.createElement( ret[1] ) ]; + jQuery.fn.attr.call( selector, context, true ); + + } else { + selector = [ doc.createElement( ret[1] ) ]; + } + + } else { + ret = jQuery.buildFragment( [ match[1] ], [ doc ] ); + selector = ( ret.cacheable ? jQuery.clone(ret.fragment) : ret.fragment ).childNodes; + } + + return jQuery.merge( this, selector ); + + // HANDLE: $("#id") + } else { + elem = document.getElementById( match[2] ); + + // Check parentNode to catch when Blackberry 4.6 returns + // nodes that are no longer in the document #6963 + if ( elem && elem.parentNode ) { + // Handle the case where IE and Opera return items + // by name instead of ID + if ( elem.id !== match[2] ) { + return rootjQuery.find( selector ); + } + + // Otherwise, we inject the element directly into the jQuery object + this.length = 1; + this[0] = elem; + } + + this.context = document; + this.selector = selector; + return this; + } + + // HANDLE: $(expr, $(...)) + } else if ( !context || context.jquery ) { + return ( context || rootjQuery ).find( selector ); + + // HANDLE: $(expr, context) + // (which is just equivalent to: $(context).find(expr) + } else { + return this.constructor( context ).find( selector ); + } + + // HANDLE: $(function) + // Shortcut for document ready + } else if ( jQuery.isFunction( selector ) ) { + return rootjQuery.ready( selector ); + } + + if ( selector.selector !== undefined ) { + this.selector = selector.selector; + this.context = selector.context; + } + + return jQuery.makeArray( selector, this ); + }, + + // Start with an empty selector + selector: "", + + // The current version of jQuery being used + jquery: "1.7.2", + + // The default length of a jQuery object is 0 + length: 0, + + // The number of elements contained in the matched element set + size: function() { + return this.length; + }, + + toArray: function() { + return slice.call( this, 0 ); + }, + + // Get the Nth element in the matched element set OR + // Get the whole matched element set as a clean array + get: function( num ) { + return num == null ? + + // Return a 'clean' array + this.toArray() : + + // Return just the object + ( num < 0 ? this[ this.length + num ] : this[ num ] ); + }, + + // Take an array of elements and push it onto the stack + // (returning the new matched element set) + pushStack: function( elems, name, selector ) { + // Build a new jQuery matched element set + var ret = this.constructor(); + + if ( jQuery.isArray( elems ) ) { + push.apply( ret, elems ); + + } else { + jQuery.merge( ret, elems ); + } + + // Add the old object onto the stack (as a reference) + ret.prevObject = this; + + ret.context = this.context; + + if ( name === "find" ) { + ret.selector = this.selector + ( this.selector ? " " : "" ) + selector; + } else if ( name ) { + ret.selector = this.selector + "." + name + "(" + selector + ")"; + } + + // Return the newly-formed element set + return ret; + }, + + // Execute a callback for every element in the matched set. + // (You can seed the arguments with an array of args, but this is + // only used internally.) + each: function( callback, args ) { + return jQuery.each( this, callback, args ); + }, + + ready: function( fn ) { + // Attach the listeners + jQuery.bindReady(); + + // Add the callback + readyList.add( fn ); + + return this; + }, + + eq: function( i ) { + i = +i; + return i === -1 ? + this.slice( i ) : + this.slice( i, i + 1 ); + }, + + first: function() { + return this.eq( 0 ); + }, + + last: function() { + return this.eq( -1 ); + }, + + slice: function() { + return this.pushStack( slice.apply( this, arguments ), + "slice", slice.call(arguments).join(",") ); + }, + + map: function( callback ) { + return this.pushStack( jQuery.map(this, function( elem, i ) { + return callback.call( elem, i, elem ); + })); + }, + + end: function() { + return this.prevObject || this.constructor(null); + }, + + // For internal use only. + // Behaves like an Array's method, not like a jQuery method. + push: push, + sort: [].sort, + splice: [].splice +}; + +// Give the init function the jQuery prototype for later instantiation +jQuery.fn.init.prototype = jQuery.fn; + +jQuery.extend = jQuery.fn.extend = function() { + var options, name, src, copy, copyIsArray, clone, + target = arguments[0] || {}, + i = 1, + length = arguments.length, + deep = false; + + // Handle a deep copy situation + if ( typeof target === "boolean" ) { + deep = target; + target = arguments[1] || {}; + // skip the boolean and the target + i = 2; + } + + // Handle case when target is a string or something (possible in deep copy) + if ( typeof target !== "object" && !jQuery.isFunction(target) ) { + target = {}; + } + + // extend jQuery itself if only one argument is passed + if ( length === i ) { + target = this; + --i; + } + + for ( ; i < length; i++ ) { + // Only deal with non-null/undefined values + if ( (options = arguments[ i ]) != null ) { + // Extend the base object + for ( name in options ) { + src = target[ name ]; + copy = options[ name ]; + + // Prevent never-ending loop + if ( target === copy ) { + continue; + } + + // Recurse if we're merging plain objects or arrays + if ( deep && copy && ( jQuery.isPlainObject(copy) || (copyIsArray = jQuery.isArray(copy)) ) ) { + if ( copyIsArray ) { + copyIsArray = false; + clone = src && jQuery.isArray(src) ? src : []; + + } else { + clone = src && jQuery.isPlainObject(src) ? src : {}; + } + + // Never move original objects, clone them + target[ name ] = jQuery.extend( deep, clone, copy ); + + // Don't bring in undefined values + } else if ( copy !== undefined ) { + target[ name ] = copy; + } + } + } + } + + // Return the modified object + return target; +}; + +jQuery.extend({ + noConflict: function( deep ) { + if ( window.$ === jQuery ) { + window.$ = _$; + } + + if ( deep && window.jQuery === jQuery ) { + window.jQuery = _jQuery; + } + + return jQuery; + }, + + // Is the DOM ready to be used? Set to true once it occurs. + isReady: false, + + // A counter to track how many items to wait for before + // the ready event fires. See #6781 + readyWait: 1, + + // Hold (or release) the ready event + holdReady: function( hold ) { + if ( hold ) { + jQuery.readyWait++; + } else { + jQuery.ready( true ); + } + }, + + // Handle when the DOM is ready + ready: function( wait ) { + // Either a released hold or an DOMready/load event and not yet ready + if ( (wait === true && !--jQuery.readyWait) || (wait !== true && !jQuery.isReady) ) { + // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443). + if ( !document.body ) { + return setTimeout( jQuery.ready, 1 ); + } + + // Remember that the DOM is ready + jQuery.isReady = true; + + // If a normal DOM Ready event fired, decrement, and wait if need be + if ( wait !== true && --jQuery.readyWait > 0 ) { + return; + } + + // If there are functions bound, to execute + readyList.fireWith( document, [ jQuery ] ); + + // Trigger any bound ready events + if ( jQuery.fn.trigger ) { + jQuery( document ).trigger( "ready" ).off( "ready" ); + } + } + }, + + bindReady: function() { + if ( readyList ) { + return; + } + + readyList = jQuery.Callbacks( "once memory" ); + + // Catch cases where $(document).ready() is called after the + // browser event has already occurred. + if ( document.readyState === "complete" ) { + // Handle it asynchronously to allow scripts the opportunity to delay ready + return setTimeout( jQuery.ready, 1 ); + } + + // Mozilla, Opera and webkit nightlies currently support this event + if ( document.addEventListener ) { + // Use the handy event callback + document.addEventListener( "DOMContentLoaded", DOMContentLoaded, false ); + + // A fallback to window.onload, that will always work + window.addEventListener( "load", jQuery.ready, false ); + + // If IE event model is used + } else if ( document.attachEvent ) { + // ensure firing before onload, + // maybe late but safe also for iframes + document.attachEvent( "onreadystatechange", DOMContentLoaded ); + + // A fallback to window.onload, that will always work + window.attachEvent( "onload", jQuery.ready ); + + // If IE and not a frame + // continually check to see if the document is ready + var toplevel = false; + + try { + toplevel = window.frameElement == null; + } catch(e) {} + + if ( document.documentElement.doScroll && toplevel ) { + doScrollCheck(); + } + } + }, + + // See test/unit/core.js for details concerning isFunction. + // Since version 1.3, DOM methods and functions like alert + // aren't supported. They return false on IE (#2968). + isFunction: function( obj ) { + return jQuery.type(obj) === "function"; + }, + + isArray: Array.isArray || function( obj ) { + return jQuery.type(obj) === "array"; + }, + + isWindow: function( obj ) { + return obj != null && obj == obj.window; + }, + + isNumeric: function( obj ) { + return !isNaN( parseFloat(obj) ) && isFinite( obj ); + }, + + type: function( obj ) { + return obj == null ? + String( obj ) : + class2type[ toString.call(obj) ] || "object"; + }, + + isPlainObject: function( obj ) { + // Must be an Object. + // Because of IE, we also have to check the presence of the constructor property. + // Make sure that DOM nodes and window objects don't pass through, as well + if ( !obj || jQuery.type(obj) !== "object" || obj.nodeType || jQuery.isWindow( obj ) ) { + return false; + } + + try { + // Not own constructor property must be Object + if ( obj.constructor && + !hasOwn.call(obj, "constructor") && + !hasOwn.call(obj.constructor.prototype, "isPrototypeOf") ) { + return false; + } + } catch ( e ) { + // IE8,9 Will throw exceptions on certain host objects #9897 + return false; + } + + // Own properties are enumerated firstly, so to speed up, + // if last one is own, then all properties are own. + + var key; + for ( key in obj ) {} + + return key === undefined || hasOwn.call( obj, key ); + }, + + isEmptyObject: function( obj ) { + for ( var name in obj ) { + return false; + } + return true; + }, + + error: function( msg ) { + throw new Error( msg ); + }, + + parseJSON: function( data ) { + if ( typeof data !== "string" || !data ) { + return null; + } + + // Make sure leading/trailing whitespace is removed (IE can't handle it) + data = jQuery.trim( data ); + + // Attempt to parse using the native JSON parser first + if ( window.JSON && window.JSON.parse ) { + return window.JSON.parse( data ); + } + + // Make sure the incoming data is actual JSON + // Logic borrowed from http://json.org/json2.js + if ( rvalidchars.test( data.replace( rvalidescape, "@" ) + .replace( rvalidtokens, "]" ) + .replace( rvalidbraces, "")) ) { + + return ( new Function( "return " + data ) )(); + + } + jQuery.error( "Invalid JSON: " + data ); + }, + + // Cross-browser xml parsing + parseXML: function( data ) { + if ( typeof data !== "string" || !data ) { + return null; + } + var xml, tmp; + try { + if ( window.DOMParser ) { // Standard + tmp = new DOMParser(); + xml = tmp.parseFromString( data , "text/xml" ); + } else { // IE + xml = new ActiveXObject( "Microsoft.XMLDOM" ); + xml.async = "false"; + xml.loadXML( data ); + } + } catch( e ) { + xml = undefined; + } + if ( !xml || !xml.documentElement || xml.getElementsByTagName( "parsererror" ).length ) { + jQuery.error( "Invalid XML: " + data ); + } + return xml; + }, + + noop: function() {}, + + // Evaluates a script in a global context + // Workarounds based on findings by Jim Driscoll + // http://weblogs.java.net/blog/driscoll/archive/2009/09/08/eval-javascript-global-context + globalEval: function( data ) { + if ( data && rnotwhite.test( data ) ) { + // We use execScript on Internet Explorer + // We use an anonymous function so that context is window + // rather than jQuery in Firefox + ( window.execScript || function( data ) { + window[ "eval" ].call( window, data ); + } )( data ); + } + }, + + // Convert dashed to camelCase; used by the css and data modules + // Microsoft forgot to hump their vendor prefix (#9572) + camelCase: function( string ) { + return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase ); + }, + + nodeName: function( elem, name ) { + return elem.nodeName && elem.nodeName.toUpperCase() === name.toUpperCase(); + }, + + // args is for internal usage only + each: function( object, callback, args ) { + var name, i = 0, + length = object.length, + isObj = length === undefined || jQuery.isFunction( object ); + + if ( args ) { + if ( isObj ) { + for ( name in object ) { + if ( callback.apply( object[ name ], args ) === false ) { + break; + } + } + } else { + for ( ; i < length; ) { + if ( callback.apply( object[ i++ ], args ) === false ) { + break; + } + } + } + + // A special, fast, case for the most common use of each + } else { + if ( isObj ) { + for ( name in object ) { + if ( callback.call( object[ name ], name, object[ name ] ) === false ) { + break; + } + } + } else { + for ( ; i < length; ) { + if ( callback.call( object[ i ], i, object[ i++ ] ) === false ) { + break; + } + } + } + } + + return object; + }, + + // Use native String.trim function wherever possible + trim: trim ? + function( text ) { + return text == null ? + "" : + trim.call( text ); + } : + + // Otherwise use our own trimming functionality + function( text ) { + return text == null ? + "" : + text.toString().replace( trimLeft, "" ).replace( trimRight, "" ); + }, + + // results is for internal usage only + makeArray: function( array, results ) { + var ret = results || []; + + if ( array != null ) { + // The window, strings (and functions) also have 'length' + // Tweaked logic slightly to handle Blackberry 4.7 RegExp issues #6930 + var type = jQuery.type( array ); + + if ( array.length == null || type === "string" || type === "function" || type === "regexp" || jQuery.isWindow( array ) ) { + push.call( ret, array ); + } else { + jQuery.merge( ret, array ); + } + } + + return ret; + }, + + inArray: function( elem, array, i ) { + var len; + + if ( array ) { + if ( indexOf ) { + return indexOf.call( array, elem, i ); + } + + len = array.length; + i = i ? i < 0 ? Math.max( 0, len + i ) : i : 0; + + for ( ; i < len; i++ ) { + // Skip accessing in sparse arrays + if ( i in array && array[ i ] === elem ) { + return i; + } + } + } + + return -1; + }, + + merge: function( first, second ) { + var i = first.length, + j = 0; + + if ( typeof second.length === "number" ) { + for ( var l = second.length; j < l; j++ ) { + first[ i++ ] = second[ j ]; + } + + } else { + while ( second[j] !== undefined ) { + first[ i++ ] = second[ j++ ]; + } + } + + first.length = i; + + return first; + }, + + grep: function( elems, callback, inv ) { + var ret = [], retVal; + inv = !!inv; + + // Go through the array, only saving the items + // that pass the validator function + for ( var i = 0, length = elems.length; i < length; i++ ) { + retVal = !!callback( elems[ i ], i ); + if ( inv !== retVal ) { + ret.push( elems[ i ] ); + } + } + + return ret; + }, + + // arg is for internal usage only + map: function( elems, callback, arg ) { + var value, key, ret = [], + i = 0, + length = elems.length, + // jquery objects are treated as arrays + isArray = elems instanceof jQuery || length !== undefined && typeof length === "number" && ( ( length > 0 && elems[ 0 ] && elems[ length -1 ] ) || length === 0 || jQuery.isArray( elems ) ) ; + + // Go through the array, translating each of the items to their + if ( isArray ) { + for ( ; i < length; i++ ) { + value = callback( elems[ i ], i, arg ); + + if ( value != null ) { + ret[ ret.length ] = value; + } + } + + // Go through every key on the object, + } else { + for ( key in elems ) { + value = callback( elems[ key ], key, arg ); + + if ( value != null ) { + ret[ ret.length ] = value; + } + } + } + + // Flatten any nested arrays + return ret.concat.apply( [], ret ); + }, + + // A global GUID counter for objects + guid: 1, + + // Bind a function to a context, optionally partially applying any + // arguments. + proxy: function( fn, context ) { + if ( typeof context === "string" ) { + var tmp = fn[ context ]; + context = fn; + fn = tmp; + } + + // Quick check to determine if target is callable, in the spec + // this throws a TypeError, but we will just return undefined. + if ( !jQuery.isFunction( fn ) ) { + return undefined; + } + + // Simulated bind + var args = slice.call( arguments, 2 ), + proxy = function() { + return fn.apply( context, args.concat( slice.call( arguments ) ) ); + }; + + // Set the guid of unique handler to the same of original handler, so it can be removed + proxy.guid = fn.guid = fn.guid || proxy.guid || jQuery.guid++; + + return proxy; + }, + + // Mutifunctional method to get and set values to a collection + // The value/s can optionally be executed if it's a function + access: function( elems, fn, key, value, chainable, emptyGet, pass ) { + var exec, + bulk = key == null, + i = 0, + length = elems.length; + + // Sets many values + if ( key && typeof key === "object" ) { + for ( i in key ) { + jQuery.access( elems, fn, i, key[i], 1, emptyGet, value ); + } + chainable = 1; + + // Sets one value + } else if ( value !== undefined ) { + // Optionally, function values get executed if exec is true + exec = pass === undefined && jQuery.isFunction( value ); + + if ( bulk ) { + // Bulk operations only iterate when executing function values + if ( exec ) { + exec = fn; + fn = function( elem, key, value ) { + return exec.call( jQuery( elem ), value ); + }; + + // Otherwise they run against the entire set + } else { + fn.call( elems, value ); + fn = null; + } + } + + if ( fn ) { + for (; i < length; i++ ) { + fn( elems[i], key, exec ? value.call( elems[i], i, fn( elems[i], key ) ) : value, pass ); + } + } + + chainable = 1; + } + + return chainable ? + elems : + + // Gets + bulk ? + fn.call( elems ) : + length ? fn( elems[0], key ) : emptyGet; + }, + + now: function() { + return ( new Date() ).getTime(); + }, + + // Use of jQuery.browser is frowned upon. + // More details: http://docs.jquery.com/Utilities/jQuery.browser + uaMatch: function( ua ) { + ua = ua.toLowerCase(); + + var match = rwebkit.exec( ua ) || + ropera.exec( ua ) || + rmsie.exec( ua ) || + ua.indexOf("compatible") < 0 && rmozilla.exec( ua ) || + []; + + return { browser: match[1] || "", version: match[2] || "0" }; + }, + + sub: function() { + function jQuerySub( selector, context ) { + return new jQuerySub.fn.init( selector, context ); + } + jQuery.extend( true, jQuerySub, this ); + jQuerySub.superclass = this; + jQuerySub.fn = jQuerySub.prototype = this(); + jQuerySub.fn.constructor = jQuerySub; + jQuerySub.sub = this.sub; + jQuerySub.fn.init = function init( selector, context ) { + if ( context && context instanceof jQuery && !(context instanceof jQuerySub) ) { + context = jQuerySub( context ); + } + + return jQuery.fn.init.call( this, selector, context, rootjQuerySub ); + }; + jQuerySub.fn.init.prototype = jQuerySub.fn; + var rootjQuerySub = jQuerySub(document); + return jQuerySub; + }, + + browser: {} +}); + +// Populate the class2type map +jQuery.each("Boolean Number String Function Array Date RegExp Object".split(" "), function(i, name) { + class2type[ "[object " + name + "]" ] = name.toLowerCase(); +}); + +browserMatch = jQuery.uaMatch( userAgent ); +if ( browserMatch.browser ) { + jQuery.browser[ browserMatch.browser ] = true; + jQuery.browser.version = browserMatch.version; +} + +// Deprecated, use jQuery.browser.webkit instead +if ( jQuery.browser.webkit ) { + jQuery.browser.safari = true; +} + +// IE doesn't match non-breaking spaces with \s +if ( rnotwhite.test( "\xA0" ) ) { + trimLeft = /^[\s\xA0]+/; + trimRight = /[\s\xA0]+$/; +} + +// All jQuery objects should point back to these +rootjQuery = jQuery(document); + +// Cleanup functions for the document ready method +if ( document.addEventListener ) { + DOMContentLoaded = function() { + document.removeEventListener( "DOMContentLoaded", DOMContentLoaded, false ); + jQuery.ready(); + }; + +} else if ( document.attachEvent ) { + DOMContentLoaded = function() { + // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443). + if ( document.readyState === "complete" ) { + document.detachEvent( "onreadystatechange", DOMContentLoaded ); + jQuery.ready(); + } + }; +} + +// The DOM ready check for Internet Explorer +function doScrollCheck() { + if ( jQuery.isReady ) { + return; + } + + try { + // If IE is used, use the trick by Diego Perini + // http://javascript.nwbox.com/IEContentLoaded/ + document.documentElement.doScroll("left"); + } catch(e) { + setTimeout( doScrollCheck, 1 ); + return; + } + + // and execute any waiting functions + jQuery.ready(); +} + +return jQuery; + +})(); + + +// String to Object flags format cache +var flagsCache = {}; + +// Convert String-formatted flags into Object-formatted ones and store in cache +function createFlags( flags ) { + var object = flagsCache[ flags ] = {}, + i, length; + flags = flags.split( /\s+/ ); + for ( i = 0, length = flags.length; i < length; i++ ) { + object[ flags[i] ] = true; + } + return object; +} + +/* + * Create a callback list using the following parameters: + * + * flags: an optional list of space-separated flags that will change how + * the callback list behaves + * + * By default a callback list will act like an event callback list and can be + * "fired" multiple times. + * + * Possible flags: + * + * once: will ensure the callback list can only be fired once (like a Deferred) + * + * memory: will keep track of previous values and will call any callback added + * after the list has been fired right away with the latest "memorized" + * values (like a Deferred) + * + * unique: will ensure a callback can only be added once (no duplicate in the list) + * + * stopOnFalse: interrupt callings when a callback returns false + * + */ +jQuery.Callbacks = function( flags ) { + + // Convert flags from String-formatted to Object-formatted + // (we check in cache first) + flags = flags ? ( flagsCache[ flags ] || createFlags( flags ) ) : {}; + + var // Actual callback list + list = [], + // Stack of fire calls for repeatable lists + stack = [], + // Last fire value (for non-forgettable lists) + memory, + // Flag to know if list was already fired + fired, + // Flag to know if list is currently firing + firing, + // First callback to fire (used internally by add and fireWith) + firingStart, + // End of the loop when firing + firingLength, + // Index of currently firing callback (modified by remove if needed) + firingIndex, + // Add one or several callbacks to the list + add = function( args ) { + var i, + length, + elem, + type, + actual; + for ( i = 0, length = args.length; i < length; i++ ) { + elem = args[ i ]; + type = jQuery.type( elem ); + if ( type === "array" ) { + // Inspect recursively + add( elem ); + } else if ( type === "function" ) { + // Add if not in unique mode and callback is not in + if ( !flags.unique || !self.has( elem ) ) { + list.push( elem ); + } + } + } + }, + // Fire callbacks + fire = function( context, args ) { + args = args || []; + memory = !flags.memory || [ context, args ]; + fired = true; + firing = true; + firingIndex = firingStart || 0; + firingStart = 0; + firingLength = list.length; + for ( ; list && firingIndex < firingLength; firingIndex++ ) { + if ( list[ firingIndex ].apply( context, args ) === false && flags.stopOnFalse ) { + memory = true; // Mark as halted + break; + } + } + firing = false; + if ( list ) { + if ( !flags.once ) { + if ( stack && stack.length ) { + memory = stack.shift(); + self.fireWith( memory[ 0 ], memory[ 1 ] ); + } + } else if ( memory === true ) { + self.disable(); + } else { + list = []; + } + } + }, + // Actual Callbacks object + self = { + // Add a callback or a collection of callbacks to the list + add: function() { + if ( list ) { + var length = list.length; + add( arguments ); + // Do we need to add the callbacks to the + // current firing batch? + if ( firing ) { + firingLength = list.length; + // With memory, if we're not firing then + // we should call right away, unless previous + // firing was halted (stopOnFalse) + } else if ( memory && memory !== true ) { + firingStart = length; + fire( memory[ 0 ], memory[ 1 ] ); + } + } + return this; + }, + // Remove a callback from the list + remove: function() { + if ( list ) { + var args = arguments, + argIndex = 0, + argLength = args.length; + for ( ; argIndex < argLength ; argIndex++ ) { + for ( var i = 0; i < list.length; i++ ) { + if ( args[ argIndex ] === list[ i ] ) { + // Handle firingIndex and firingLength + if ( firing ) { + if ( i <= firingLength ) { + firingLength--; + if ( i <= firingIndex ) { + firingIndex--; + } + } + } + // Remove the element + list.splice( i--, 1 ); + // If we have some unicity property then + // we only need to do this once + if ( flags.unique ) { + break; + } + } + } + } + } + return this; + }, + // Control if a given callback is in the list + has: function( fn ) { + if ( list ) { + var i = 0, + length = list.length; + for ( ; i < length; i++ ) { + if ( fn === list[ i ] ) { + return true; + } + } + } + return false; + }, + // Remove all callbacks from the list + empty: function() { + list = []; + return this; + }, + // Have the list do nothing anymore + disable: function() { + list = stack = memory = undefined; + return this; + }, + // Is it disabled? + disabled: function() { + return !list; + }, + // Lock the list in its current state + lock: function() { + stack = undefined; + if ( !memory || memory === true ) { + self.disable(); + } + return this; + }, + // Is it locked? + locked: function() { + return !stack; + }, + // Call all callbacks with the given context and arguments + fireWith: function( context, args ) { + if ( stack ) { + if ( firing ) { + if ( !flags.once ) { + stack.push( [ context, args ] ); + } + } else if ( !( flags.once && memory ) ) { + fire( context, args ); + } + } + return this; + }, + // Call all the callbacks with the given arguments + fire: function() { + self.fireWith( this, arguments ); + return this; + }, + // To know if the callbacks have already been called at least once + fired: function() { + return !!fired; + } + }; + + return self; +}; + + + + +var // Static reference to slice + sliceDeferred = [].slice; + +jQuery.extend({ + + Deferred: function( func ) { + var doneList = jQuery.Callbacks( "once memory" ), + failList = jQuery.Callbacks( "once memory" ), + progressList = jQuery.Callbacks( "memory" ), + state = "pending", + lists = { + resolve: doneList, + reject: failList, + notify: progressList + }, + promise = { + done: doneList.add, + fail: failList.add, + progress: progressList.add, + + state: function() { + return state; + }, + + // Deprecated + isResolved: doneList.fired, + isRejected: failList.fired, + + then: function( doneCallbacks, failCallbacks, progressCallbacks ) { + deferred.done( doneCallbacks ).fail( failCallbacks ).progress( progressCallbacks ); + return this; + }, + always: function() { + deferred.done.apply( deferred, arguments ).fail.apply( deferred, arguments ); + return this; + }, + pipe: function( fnDone, fnFail, fnProgress ) { + return jQuery.Deferred(function( newDefer ) { + jQuery.each( { + done: [ fnDone, "resolve" ], + fail: [ fnFail, "reject" ], + progress: [ fnProgress, "notify" ] + }, function( handler, data ) { + var fn = data[ 0 ], + action = data[ 1 ], + returned; + if ( jQuery.isFunction( fn ) ) { + deferred[ handler ](function() { + returned = fn.apply( this, arguments ); + if ( returned && jQuery.isFunction( returned.promise ) ) { + returned.promise().then( newDefer.resolve, newDefer.reject, newDefer.notify ); + } else { + newDefer[ action + "With" ]( this === deferred ? newDefer : this, [ returned ] ); + } + }); + } else { + deferred[ handler ]( newDefer[ action ] ); + } + }); + }).promise(); + }, + // Get a promise for this deferred + // If obj is provided, the promise aspect is added to the object + promise: function( obj ) { + if ( obj == null ) { + obj = promise; + } else { + for ( var key in promise ) { + obj[ key ] = promise[ key ]; + } + } + return obj; + } + }, + deferred = promise.promise({}), + key; + + for ( key in lists ) { + deferred[ key ] = lists[ key ].fire; + deferred[ key + "With" ] = lists[ key ].fireWith; + } + + // Handle state + deferred.done( function() { + state = "resolved"; + }, failList.disable, progressList.lock ).fail( function() { + state = "rejected"; + }, doneList.disable, progressList.lock ); + + // Call given func if any + if ( func ) { + func.call( deferred, deferred ); + } + + // All done! + return deferred; + }, + + // Deferred helper + when: function( firstParam ) { + var args = sliceDeferred.call( arguments, 0 ), + i = 0, + length = args.length, + pValues = new Array( length ), + count = length, + pCount = length, + deferred = length <= 1 && firstParam && jQuery.isFunction( firstParam.promise ) ? + firstParam : + jQuery.Deferred(), + promise = deferred.promise(); + function resolveFunc( i ) { + return function( value ) { + args[ i ] = arguments.length > 1 ? sliceDeferred.call( arguments, 0 ) : value; + if ( !( --count ) ) { + deferred.resolveWith( deferred, args ); + } + }; + } + function progressFunc( i ) { + return function( value ) { + pValues[ i ] = arguments.length > 1 ? sliceDeferred.call( arguments, 0 ) : value; + deferred.notifyWith( promise, pValues ); + }; + } + if ( length > 1 ) { + for ( ; i < length; i++ ) { + if ( args[ i ] && args[ i ].promise && jQuery.isFunction( args[ i ].promise ) ) { + args[ i ].promise().then( resolveFunc(i), deferred.reject, progressFunc(i) ); + } else { + --count; + } + } + if ( !count ) { + deferred.resolveWith( deferred, args ); + } + } else if ( deferred !== firstParam ) { + deferred.resolveWith( deferred, length ? [ firstParam ] : [] ); + } + return promise; + } +}); + + + + +jQuery.support = (function() { + + var support, + all, + a, + select, + opt, + input, + fragment, + tds, + events, + eventName, + i, + isSupported, + div = document.createElement( "div" ), + documentElement = document.documentElement; + + // Preliminary tests + div.setAttribute("className", "t"); + div.innerHTML = "
a"; + + all = div.getElementsByTagName( "*" ); + a = div.getElementsByTagName( "a" )[ 0 ]; + + // Can't get basic test support + if ( !all || !all.length || !a ) { + return {}; + } + + // First batch of supports tests + select = document.createElement( "select" ); + opt = select.appendChild( document.createElement("option") ); + input = div.getElementsByTagName( "input" )[ 0 ]; + + support = { + // IE strips leading whitespace when .innerHTML is used + leadingWhitespace: ( div.firstChild.nodeType === 3 ), + + // Make sure that tbody elements aren't automatically inserted + // IE will insert them into empty tables + tbody: !div.getElementsByTagName("tbody").length, + + // Make sure that link elements get serialized correctly by innerHTML + // This requires a wrapper element in IE + htmlSerialize: !!div.getElementsByTagName("link").length, + + // Get the style information from getAttribute + // (IE uses .cssText instead) + style: /top/.test( a.getAttribute("style") ), + + // Make sure that URLs aren't manipulated + // (IE normalizes it by default) + hrefNormalized: ( a.getAttribute("href") === "/a" ), + + // Make sure that element opacity exists + // (IE uses filter instead) + // Use a regex to work around a WebKit issue. See #5145 + opacity: /^0.55/.test( a.style.opacity ), + + // Verify style float existence + // (IE uses styleFloat instead of cssFloat) + cssFloat: !!a.style.cssFloat, + + // Make sure that if no value is specified for a checkbox + // that it defaults to "on". + // (WebKit defaults to "" instead) + checkOn: ( input.value === "on" ), + + // Make sure that a selected-by-default option has a working selected property. + // (WebKit defaults to false instead of true, IE too, if it's in an optgroup) + optSelected: opt.selected, + + // Test setAttribute on camelCase class. If it works, we need attrFixes when doing get/setAttribute (ie6/7) + getSetAttribute: div.className !== "t", + + // Tests for enctype support on a form(#6743) + enctype: !!document.createElement("form").enctype, + + // Makes sure cloning an html5 element does not cause problems + // Where outerHTML is undefined, this still works + html5Clone: document.createElement("nav").cloneNode( true ).outerHTML !== "<:nav>", + + // Will be defined later + submitBubbles: true, + changeBubbles: true, + focusinBubbles: false, + deleteExpando: true, + noCloneEvent: true, + inlineBlockNeedsLayout: false, + shrinkWrapBlocks: false, + reliableMarginRight: true, + pixelMargin: true + }; + + // jQuery.boxModel DEPRECATED in 1.3, use jQuery.support.boxModel instead + jQuery.boxModel = support.boxModel = (document.compatMode === "CSS1Compat"); + + // Make sure checked status is properly cloned + input.checked = true; + support.noCloneChecked = input.cloneNode( true ).checked; + + // Make sure that the options inside disabled selects aren't marked as disabled + // (WebKit marks them as disabled) + select.disabled = true; + support.optDisabled = !opt.disabled; + + // Test to see if it's possible to delete an expando from an element + // Fails in Internet Explorer + try { + delete div.test; + } catch( e ) { + support.deleteExpando = false; + } + + if ( !div.addEventListener && div.attachEvent && div.fireEvent ) { + div.attachEvent( "onclick", function() { + // Cloning a node shouldn't copy over any + // bound event handlers (IE does this) + support.noCloneEvent = false; + }); + div.cloneNode( true ).fireEvent( "onclick" ); + } + + // Check if a radio maintains its value + // after being appended to the DOM + input = document.createElement("input"); + input.value = "t"; + input.setAttribute("type", "radio"); + support.radioValue = input.value === "t"; + + input.setAttribute("checked", "checked"); + + // #11217 - WebKit loses check when the name is after the checked attribute + input.setAttribute( "name", "t" ); + + div.appendChild( input ); + fragment = document.createDocumentFragment(); + fragment.appendChild( div.lastChild ); + + // WebKit doesn't clone checked state correctly in fragments + support.checkClone = fragment.cloneNode( true ).cloneNode( true ).lastChild.checked; + + // Check if a disconnected checkbox will retain its checked + // value of true after appended to the DOM (IE6/7) + support.appendChecked = input.checked; + + fragment.removeChild( input ); + fragment.appendChild( div ); + + // Technique from Juriy Zaytsev + // http://perfectionkills.com/detecting-event-support-without-browser-sniffing/ + // We only care about the case where non-standard event systems + // are used, namely in IE. Short-circuiting here helps us to + // avoid an eval call (in setAttribute) which can cause CSP + // to go haywire. See: https://developer.mozilla.org/en/Security/CSP + if ( div.attachEvent ) { + for ( i in { + submit: 1, + change: 1, + focusin: 1 + }) { + eventName = "on" + i; + isSupported = ( eventName in div ); + if ( !isSupported ) { + div.setAttribute( eventName, "return;" ); + isSupported = ( typeof div[ eventName ] === "function" ); + } + support[ i + "Bubbles" ] = isSupported; + } + } + + fragment.removeChild( div ); + + // Null elements to avoid leaks in IE + fragment = select = opt = div = input = null; + + // Run tests that need a body at doc ready + jQuery(function() { + var container, outer, inner, table, td, offsetSupport, + marginDiv, conMarginTop, style, html, positionTopLeftWidthHeight, + paddingMarginBorderVisibility, paddingMarginBorder, + body = document.getElementsByTagName("body")[0]; + + if ( !body ) { + // Return for frameset docs that don't have a body + return; + } + + conMarginTop = 1; + paddingMarginBorder = "padding:0;margin:0;border:"; + positionTopLeftWidthHeight = "position:absolute;top:0;left:0;width:1px;height:1px;"; + paddingMarginBorderVisibility = paddingMarginBorder + "0;visibility:hidden;"; + style = "style='" + positionTopLeftWidthHeight + paddingMarginBorder + "5px solid #000;"; + html = "
" + + "" + + "
"; + + container = document.createElement("div"); + container.style.cssText = paddingMarginBorderVisibility + "width:0;height:0;position:static;top:0;margin-top:" + conMarginTop + "px"; + body.insertBefore( container, body.firstChild ); + + // Construct the test element + div = document.createElement("div"); + container.appendChild( div ); + + // Check if table cells still have offsetWidth/Height when they are set + // to display:none and there are still other visible table cells in a + // table row; if so, offsetWidth/Height are not reliable for use when + // determining if an element has been hidden directly using + // display:none (it is still safe to use offsets if a parent element is + // hidden; don safety goggles and see bug #4512 for more information). + // (only IE 8 fails this test) + div.innerHTML = "
t
"; + tds = div.getElementsByTagName( "td" ); + isSupported = ( tds[ 0 ].offsetHeight === 0 ); + + tds[ 0 ].style.display = ""; + tds[ 1 ].style.display = "none"; + + // Check if empty table cells still have offsetWidth/Height + // (IE <= 8 fail this test) + support.reliableHiddenOffsets = isSupported && ( tds[ 0 ].offsetHeight === 0 ); + + // Check if div with explicit width and no margin-right incorrectly + // gets computed margin-right based on width of container. For more + // info see bug #3333 + // Fails in WebKit before Feb 2011 nightlies + // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right + if ( window.getComputedStyle ) { + div.innerHTML = ""; + marginDiv = document.createElement( "div" ); + marginDiv.style.width = "0"; + marginDiv.style.marginRight = "0"; + div.style.width = "2px"; + div.appendChild( marginDiv ); + support.reliableMarginRight = + ( parseInt( ( window.getComputedStyle( marginDiv, null ) || { marginRight: 0 } ).marginRight, 10 ) || 0 ) === 0; + } + + if ( typeof div.style.zoom !== "undefined" ) { + // Check if natively block-level elements act like inline-block + // elements when setting their display to 'inline' and giving + // them layout + // (IE < 8 does this) + div.innerHTML = ""; + div.style.width = div.style.padding = "1px"; + div.style.border = 0; + div.style.overflow = "hidden"; + div.style.display = "inline"; + div.style.zoom = 1; + support.inlineBlockNeedsLayout = ( div.offsetWidth === 3 ); + + // Check if elements with layout shrink-wrap their children + // (IE 6 does this) + div.style.display = "block"; + div.style.overflow = "visible"; + div.innerHTML = "
"; + support.shrinkWrapBlocks = ( div.offsetWidth !== 3 ); + } + + div.style.cssText = positionTopLeftWidthHeight + paddingMarginBorderVisibility; + div.innerHTML = html; + + outer = div.firstChild; + inner = outer.firstChild; + td = outer.nextSibling.firstChild.firstChild; + + offsetSupport = { + doesNotAddBorder: ( inner.offsetTop !== 5 ), + doesAddBorderForTableAndCells: ( td.offsetTop === 5 ) + }; + + inner.style.position = "fixed"; + inner.style.top = "20px"; + + // safari subtracts parent border width here which is 5px + offsetSupport.fixedPosition = ( inner.offsetTop === 20 || inner.offsetTop === 15 ); + inner.style.position = inner.style.top = ""; + + outer.style.overflow = "hidden"; + outer.style.position = "relative"; + + offsetSupport.subtractsBorderForOverflowNotVisible = ( inner.offsetTop === -5 ); + offsetSupport.doesNotIncludeMarginInBodyOffset = ( body.offsetTop !== conMarginTop ); + + if ( window.getComputedStyle ) { + div.style.marginTop = "1%"; + support.pixelMargin = ( window.getComputedStyle( div, null ) || { marginTop: 0 } ).marginTop !== "1%"; + } + + if ( typeof container.style.zoom !== "undefined" ) { + container.style.zoom = 1; + } + + body.removeChild( container ); + marginDiv = div = container = null; + + jQuery.extend( support, offsetSupport ); + }); + + return support; +})(); + + + + +var rbrace = /^(?:\{.*\}|\[.*\])$/, + rmultiDash = /([A-Z])/g; + +jQuery.extend({ + cache: {}, + + // Please use with caution + uuid: 0, + + // Unique for each copy of jQuery on the page + // Non-digits removed to match rinlinejQuery + expando: "jQuery" + ( jQuery.fn.jquery + Math.random() ).replace( /\D/g, "" ), + + // The following elements throw uncatchable exceptions if you + // attempt to add expando properties to them. + noData: { + "embed": true, + // Ban all objects except for Flash (which handle expandos) + "object": "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000", + "applet": true + }, + + hasData: function( elem ) { + elem = elem.nodeType ? jQuery.cache[ elem[jQuery.expando] ] : elem[ jQuery.expando ]; + return !!elem && !isEmptyDataObject( elem ); + }, + + data: function( elem, name, data, pvt /* Internal Use Only */ ) { + if ( !jQuery.acceptData( elem ) ) { + return; + } + + var privateCache, thisCache, ret, + internalKey = jQuery.expando, + getByName = typeof name === "string", + + // We have to handle DOM nodes and JS objects differently because IE6-7 + // can't GC object references properly across the DOM-JS boundary + isNode = elem.nodeType, + + // Only DOM nodes need the global jQuery cache; JS object data is + // attached directly to the object so GC can occur automatically + cache = isNode ? jQuery.cache : elem, + + // Only defining an ID for JS objects if its cache already exists allows + // the code to shortcut on the same path as a DOM node with no cache + id = isNode ? elem[ internalKey ] : elem[ internalKey ] && internalKey, + isEvents = name === "events"; + + // Avoid doing any more work than we need to when trying to get data on an + // object that has no data at all + if ( (!id || !cache[id] || (!isEvents && !pvt && !cache[id].data)) && getByName && data === undefined ) { + return; + } + + if ( !id ) { + // Only DOM nodes need a new unique ID for each element since their data + // ends up in the global cache + if ( isNode ) { + elem[ internalKey ] = id = ++jQuery.uuid; + } else { + id = internalKey; + } + } + + if ( !cache[ id ] ) { + cache[ id ] = {}; + + // Avoids exposing jQuery metadata on plain JS objects when the object + // is serialized using JSON.stringify + if ( !isNode ) { + cache[ id ].toJSON = jQuery.noop; + } + } + + // An object can be passed to jQuery.data instead of a key/value pair; this gets + // shallow copied over onto the existing cache + if ( typeof name === "object" || typeof name === "function" ) { + if ( pvt ) { + cache[ id ] = jQuery.extend( cache[ id ], name ); + } else { + cache[ id ].data = jQuery.extend( cache[ id ].data, name ); + } + } + + privateCache = thisCache = cache[ id ]; + + // jQuery data() is stored in a separate object inside the object's internal data + // cache in order to avoid key collisions between internal data and user-defined + // data. + if ( !pvt ) { + if ( !thisCache.data ) { + thisCache.data = {}; + } + + thisCache = thisCache.data; + } + + if ( data !== undefined ) { + thisCache[ jQuery.camelCase( name ) ] = data; + } + + // Users should not attempt to inspect the internal events object using jQuery.data, + // it is undocumented and subject to change. But does anyone listen? No. + if ( isEvents && !thisCache[ name ] ) { + return privateCache.events; + } + + // Check for both converted-to-camel and non-converted data property names + // If a data property was specified + if ( getByName ) { + + // First Try to find as-is property data + ret = thisCache[ name ]; + + // Test for null|undefined property data + if ( ret == null ) { + + // Try to find the camelCased property + ret = thisCache[ jQuery.camelCase( name ) ]; + } + } else { + ret = thisCache; + } + + return ret; + }, + + removeData: function( elem, name, pvt /* Internal Use Only */ ) { + if ( !jQuery.acceptData( elem ) ) { + return; + } + + var thisCache, i, l, + + // Reference to internal data cache key + internalKey = jQuery.expando, + + isNode = elem.nodeType, + + // See jQuery.data for more information + cache = isNode ? jQuery.cache : elem, + + // See jQuery.data for more information + id = isNode ? elem[ internalKey ] : internalKey; + + // If there is already no cache entry for this object, there is no + // purpose in continuing + if ( !cache[ id ] ) { + return; + } + + if ( name ) { + + thisCache = pvt ? cache[ id ] : cache[ id ].data; + + if ( thisCache ) { + + // Support array or space separated string names for data keys + if ( !jQuery.isArray( name ) ) { + + // try the string as a key before any manipulation + if ( name in thisCache ) { + name = [ name ]; + } else { + + // split the camel cased version by spaces unless a key with the spaces exists + name = jQuery.camelCase( name ); + if ( name in thisCache ) { + name = [ name ]; + } else { + name = name.split( " " ); + } + } + } + + for ( i = 0, l = name.length; i < l; i++ ) { + delete thisCache[ name[i] ]; + } + + // If there is no data left in the cache, we want to continue + // and let the cache object itself get destroyed + if ( !( pvt ? isEmptyDataObject : jQuery.isEmptyObject )( thisCache ) ) { + return; + } + } + } + + // See jQuery.data for more information + if ( !pvt ) { + delete cache[ id ].data; + + // Don't destroy the parent cache unless the internal data object + // had been the only thing left in it + if ( !isEmptyDataObject(cache[ id ]) ) { + return; + } + } + + // Browsers that fail expando deletion also refuse to delete expandos on + // the window, but it will allow it on all other JS objects; other browsers + // don't care + // Ensure that `cache` is not a window object #10080 + if ( jQuery.support.deleteExpando || !cache.setInterval ) { + delete cache[ id ]; + } else { + cache[ id ] = null; + } + + // We destroyed the cache and need to eliminate the expando on the node to avoid + // false lookups in the cache for entries that no longer exist + if ( isNode ) { + // IE does not allow us to delete expando properties from nodes, + // nor does it have a removeAttribute function on Document nodes; + // we must handle all of these cases + if ( jQuery.support.deleteExpando ) { + delete elem[ internalKey ]; + } else if ( elem.removeAttribute ) { + elem.removeAttribute( internalKey ); + } else { + elem[ internalKey ] = null; + } + } + }, + + // For internal use only. + _data: function( elem, name, data ) { + return jQuery.data( elem, name, data, true ); + }, + + // A method for determining if a DOM node can handle the data expando + acceptData: function( elem ) { + if ( elem.nodeName ) { + var match = jQuery.noData[ elem.nodeName.toLowerCase() ]; + + if ( match ) { + return !(match === true || elem.getAttribute("classid") !== match); + } + } + + return true; + } +}); + +jQuery.fn.extend({ + data: function( key, value ) { + var parts, part, attr, name, l, + elem = this[0], + i = 0, + data = null; + + // Gets all values + if ( key === undefined ) { + if ( this.length ) { + data = jQuery.data( elem ); + + if ( elem.nodeType === 1 && !jQuery._data( elem, "parsedAttrs" ) ) { + attr = elem.attributes; + for ( l = attr.length; i < l; i++ ) { + name = attr[i].name; + + if ( name.indexOf( "data-" ) === 0 ) { + name = jQuery.camelCase( name.substring(5) ); + + dataAttr( elem, name, data[ name ] ); + } + } + jQuery._data( elem, "parsedAttrs", true ); + } + } + + return data; + } + + // Sets multiple values + if ( typeof key === "object" ) { + return this.each(function() { + jQuery.data( this, key ); + }); + } + + parts = key.split( ".", 2 ); + parts[1] = parts[1] ? "." + parts[1] : ""; + part = parts[1] + "!"; + + return jQuery.access( this, function( value ) { + + if ( value === undefined ) { + data = this.triggerHandler( "getData" + part, [ parts[0] ] ); + + // Try to fetch any internally stored data first + if ( data === undefined && elem ) { + data = jQuery.data( elem, key ); + data = dataAttr( elem, key, data ); + } + + return data === undefined && parts[1] ? + this.data( parts[0] ) : + data; + } + + parts[1] = value; + this.each(function() { + var self = jQuery( this ); + + self.triggerHandler( "setData" + part, parts ); + jQuery.data( this, key, value ); + self.triggerHandler( "changeData" + part, parts ); + }); + }, null, value, arguments.length > 1, null, false ); + }, + + removeData: function( key ) { + return this.each(function() { + jQuery.removeData( this, key ); + }); + } +}); + +function dataAttr( elem, key, data ) { + // If nothing was found internally, try to fetch any + // data from the HTML5 data-* attribute + if ( data === undefined && elem.nodeType === 1 ) { + + var name = "data-" + key.replace( rmultiDash, "-$1" ).toLowerCase(); + + data = elem.getAttribute( name ); + + if ( typeof data === "string" ) { + try { + data = data === "true" ? true : + data === "false" ? false : + data === "null" ? null : + jQuery.isNumeric( data ) ? +data : + rbrace.test( data ) ? jQuery.parseJSON( data ) : + data; + } catch( e ) {} + + // Make sure we set the data so it isn't changed later + jQuery.data( elem, key, data ); + + } else { + data = undefined; + } + } + + return data; +} + +// checks a cache object for emptiness +function isEmptyDataObject( obj ) { + for ( var name in obj ) { + + // if the public data object is empty, the private is still empty + if ( name === "data" && jQuery.isEmptyObject( obj[name] ) ) { + continue; + } + if ( name !== "toJSON" ) { + return false; + } + } + + return true; +} + + + + +function handleQueueMarkDefer( elem, type, src ) { + var deferDataKey = type + "defer", + queueDataKey = type + "queue", + markDataKey = type + "mark", + defer = jQuery._data( elem, deferDataKey ); + if ( defer && + ( src === "queue" || !jQuery._data(elem, queueDataKey) ) && + ( src === "mark" || !jQuery._data(elem, markDataKey) ) ) { + // Give room for hard-coded callbacks to fire first + // and eventually mark/queue something else on the element + setTimeout( function() { + if ( !jQuery._data( elem, queueDataKey ) && + !jQuery._data( elem, markDataKey ) ) { + jQuery.removeData( elem, deferDataKey, true ); + defer.fire(); + } + }, 0 ); + } +} + +jQuery.extend({ + + _mark: function( elem, type ) { + if ( elem ) { + type = ( type || "fx" ) + "mark"; + jQuery._data( elem, type, (jQuery._data( elem, type ) || 0) + 1 ); + } + }, + + _unmark: function( force, elem, type ) { + if ( force !== true ) { + type = elem; + elem = force; + force = false; + } + if ( elem ) { + type = type || "fx"; + var key = type + "mark", + count = force ? 0 : ( (jQuery._data( elem, key ) || 1) - 1 ); + if ( count ) { + jQuery._data( elem, key, count ); + } else { + jQuery.removeData( elem, key, true ); + handleQueueMarkDefer( elem, type, "mark" ); + } + } + }, + + queue: function( elem, type, data ) { + var q; + if ( elem ) { + type = ( type || "fx" ) + "queue"; + q = jQuery._data( elem, type ); + + // Speed up dequeue by getting out quickly if this is just a lookup + if ( data ) { + if ( !q || jQuery.isArray(data) ) { + q = jQuery._data( elem, type, jQuery.makeArray(data) ); + } else { + q.push( data ); + } + } + return q || []; + } + }, + + dequeue: function( elem, type ) { + type = type || "fx"; + + var queue = jQuery.queue( elem, type ), + fn = queue.shift(), + hooks = {}; + + // If the fx queue is dequeued, always remove the progress sentinel + if ( fn === "inprogress" ) { + fn = queue.shift(); + } + + if ( fn ) { + // Add a progress sentinel to prevent the fx queue from being + // automatically dequeued + if ( type === "fx" ) { + queue.unshift( "inprogress" ); + } + + jQuery._data( elem, type + ".run", hooks ); + fn.call( elem, function() { + jQuery.dequeue( elem, type ); + }, hooks ); + } + + if ( !queue.length ) { + jQuery.removeData( elem, type + "queue " + type + ".run", true ); + handleQueueMarkDefer( elem, type, "queue" ); + } + } +}); + +jQuery.fn.extend({ + queue: function( type, data ) { + var setter = 2; + + if ( typeof type !== "string" ) { + data = type; + type = "fx"; + setter--; + } + + if ( arguments.length < setter ) { + return jQuery.queue( this[0], type ); + } + + return data === undefined ? + this : + this.each(function() { + var queue = jQuery.queue( this, type, data ); + + if ( type === "fx" && queue[0] !== "inprogress" ) { + jQuery.dequeue( this, type ); + } + }); + }, + dequeue: function( type ) { + return this.each(function() { + jQuery.dequeue( this, type ); + }); + }, + // Based off of the plugin by Clint Helfers, with permission. + // http://blindsignals.com/index.php/2009/07/jquery-delay/ + delay: function( time, type ) { + time = jQuery.fx ? jQuery.fx.speeds[ time ] || time : time; + type = type || "fx"; + + return this.queue( type, function( next, hooks ) { + var timeout = setTimeout( next, time ); + hooks.stop = function() { + clearTimeout( timeout ); + }; + }); + }, + clearQueue: function( type ) { + return this.queue( type || "fx", [] ); + }, + // Get a promise resolved when queues of a certain type + // are emptied (fx is the type by default) + promise: function( type, object ) { + if ( typeof type !== "string" ) { + object = type; + type = undefined; + } + type = type || "fx"; + var defer = jQuery.Deferred(), + elements = this, + i = elements.length, + count = 1, + deferDataKey = type + "defer", + queueDataKey = type + "queue", + markDataKey = type + "mark", + tmp; + function resolve() { + if ( !( --count ) ) { + defer.resolveWith( elements, [ elements ] ); + } + } + while( i-- ) { + if (( tmp = jQuery.data( elements[ i ], deferDataKey, undefined, true ) || + ( jQuery.data( elements[ i ], queueDataKey, undefined, true ) || + jQuery.data( elements[ i ], markDataKey, undefined, true ) ) && + jQuery.data( elements[ i ], deferDataKey, jQuery.Callbacks( "once memory" ), true ) )) { + count++; + tmp.add( resolve ); + } + } + resolve(); + return defer.promise( object ); + } +}); + + + + +var rclass = /[\n\t\r]/g, + rspace = /\s+/, + rreturn = /\r/g, + rtype = /^(?:button|input)$/i, + rfocusable = /^(?:button|input|object|select|textarea)$/i, + rclickable = /^a(?:rea)?$/i, + rboolean = /^(?:autofocus|autoplay|async|checked|controls|defer|disabled|hidden|loop|multiple|open|readonly|required|scoped|selected)$/i, + getSetAttribute = jQuery.support.getSetAttribute, + nodeHook, boolHook, fixSpecified; + +jQuery.fn.extend({ + attr: function( name, value ) { + return jQuery.access( this, jQuery.attr, name, value, arguments.length > 1 ); + }, + + removeAttr: function( name ) { + return this.each(function() { + jQuery.removeAttr( this, name ); + }); + }, + + prop: function( name, value ) { + return jQuery.access( this, jQuery.prop, name, value, arguments.length > 1 ); + }, + + removeProp: function( name ) { + name = jQuery.propFix[ name ] || name; + return this.each(function() { + // try/catch handles cases where IE balks (such as removing a property on window) + try { + this[ name ] = undefined; + delete this[ name ]; + } catch( e ) {} + }); + }, + + addClass: function( value ) { + var classNames, i, l, elem, + setClass, c, cl; + + if ( jQuery.isFunction( value ) ) { + return this.each(function( j ) { + jQuery( this ).addClass( value.call(this, j, this.className) ); + }); + } + + if ( value && typeof value === "string" ) { + classNames = value.split( rspace ); + + for ( i = 0, l = this.length; i < l; i++ ) { + elem = this[ i ]; + + if ( elem.nodeType === 1 ) { + if ( !elem.className && classNames.length === 1 ) { + elem.className = value; + + } else { + setClass = " " + elem.className + " "; + + for ( c = 0, cl = classNames.length; c < cl; c++ ) { + if ( !~setClass.indexOf( " " + classNames[ c ] + " " ) ) { + setClass += classNames[ c ] + " "; + } + } + elem.className = jQuery.trim( setClass ); + } + } + } + } + + return this; + }, + + removeClass: function( value ) { + var classNames, i, l, elem, className, c, cl; + + if ( jQuery.isFunction( value ) ) { + return this.each(function( j ) { + jQuery( this ).removeClass( value.call(this, j, this.className) ); + }); + } + + if ( (value && typeof value === "string") || value === undefined ) { + classNames = ( value || "" ).split( rspace ); + + for ( i = 0, l = this.length; i < l; i++ ) { + elem = this[ i ]; + + if ( elem.nodeType === 1 && elem.className ) { + if ( value ) { + className = (" " + elem.className + " ").replace( rclass, " " ); + for ( c = 0, cl = classNames.length; c < cl; c++ ) { + className = className.replace(" " + classNames[ c ] + " ", " "); + } + elem.className = jQuery.trim( className ); + + } else { + elem.className = ""; + } + } + } + } + + return this; + }, + + toggleClass: function( value, stateVal ) { + var type = typeof value, + isBool = typeof stateVal === "boolean"; + + if ( jQuery.isFunction( value ) ) { + return this.each(function( i ) { + jQuery( this ).toggleClass( value.call(this, i, this.className, stateVal), stateVal ); + }); + } + + return this.each(function() { + if ( type === "string" ) { + // toggle individual class names + var className, + i = 0, + self = jQuery( this ), + state = stateVal, + classNames = value.split( rspace ); + + while ( (className = classNames[ i++ ]) ) { + // check each className given, space seperated list + state = isBool ? state : !self.hasClass( className ); + self[ state ? "addClass" : "removeClass" ]( className ); + } + + } else if ( type === "undefined" || type === "boolean" ) { + if ( this.className ) { + // store className if set + jQuery._data( this, "__className__", this.className ); + } + + // toggle whole className + this.className = this.className || value === false ? "" : jQuery._data( this, "__className__" ) || ""; + } + }); + }, + + hasClass: function( selector ) { + var className = " " + selector + " ", + i = 0, + l = this.length; + for ( ; i < l; i++ ) { + if ( this[i].nodeType === 1 && (" " + this[i].className + " ").replace(rclass, " ").indexOf( className ) > -1 ) { + return true; + } + } + + return false; + }, + + val: function( value ) { + var hooks, ret, isFunction, + elem = this[0]; + + if ( !arguments.length ) { + if ( elem ) { + hooks = jQuery.valHooks[ elem.type ] || jQuery.valHooks[ elem.nodeName.toLowerCase() ]; + + if ( hooks && "get" in hooks && (ret = hooks.get( elem, "value" )) !== undefined ) { + return ret; + } + + ret = elem.value; + + return typeof ret === "string" ? + // handle most common string cases + ret.replace(rreturn, "") : + // handle cases where value is null/undef or number + ret == null ? "" : ret; + } + + return; + } + + isFunction = jQuery.isFunction( value ); + + return this.each(function( i ) { + var self = jQuery(this), val; + + if ( this.nodeType !== 1 ) { + return; + } + + if ( isFunction ) { + val = value.call( this, i, self.val() ); + } else { + val = value; + } + + // Treat null/undefined as ""; convert numbers to string + if ( val == null ) { + val = ""; + } else if ( typeof val === "number" ) { + val += ""; + } else if ( jQuery.isArray( val ) ) { + val = jQuery.map(val, function ( value ) { + return value == null ? "" : value + ""; + }); + } + + hooks = jQuery.valHooks[ this.type ] || jQuery.valHooks[ this.nodeName.toLowerCase() ]; + + // If set returns undefined, fall back to normal setting + if ( !hooks || !("set" in hooks) || hooks.set( this, val, "value" ) === undefined ) { + this.value = val; + } + }); + } +}); + +jQuery.extend({ + valHooks: { + option: { + get: function( elem ) { + // attributes.value is undefined in Blackberry 4.7 but + // uses .value. See #6932 + var val = elem.attributes.value; + return !val || val.specified ? elem.value : elem.text; + } + }, + select: { + get: function( elem ) { + var value, i, max, option, + index = elem.selectedIndex, + values = [], + options = elem.options, + one = elem.type === "select-one"; + + // Nothing was selected + if ( index < 0 ) { + return null; + } + + // Loop through all the selected options + i = one ? index : 0; + max = one ? index + 1 : options.length; + for ( ; i < max; i++ ) { + option = options[ i ]; + + // Don't return options that are disabled or in a disabled optgroup + if ( option.selected && (jQuery.support.optDisabled ? !option.disabled : option.getAttribute("disabled") === null) && + (!option.parentNode.disabled || !jQuery.nodeName( option.parentNode, "optgroup" )) ) { + + // Get the specific value for the option + value = jQuery( option ).val(); + + // We don't need an array for one selects + if ( one ) { + return value; + } + + // Multi-Selects return an array + values.push( value ); + } + } + + // Fixes Bug #2551 -- select.val() broken in IE after form.reset() + if ( one && !values.length && options.length ) { + return jQuery( options[ index ] ).val(); + } + + return values; + }, + + set: function( elem, value ) { + var values = jQuery.makeArray( value ); + + jQuery(elem).find("option").each(function() { + this.selected = jQuery.inArray( jQuery(this).val(), values ) >= 0; + }); + + if ( !values.length ) { + elem.selectedIndex = -1; + } + return values; + } + } + }, + + attrFn: { + val: true, + css: true, + html: true, + text: true, + data: true, + width: true, + height: true, + offset: true + }, + + attr: function( elem, name, value, pass ) { + var ret, hooks, notxml, + nType = elem.nodeType; + + // don't get/set attributes on text, comment and attribute nodes + if ( !elem || nType === 3 || nType === 8 || nType === 2 ) { + return; + } + + if ( pass && name in jQuery.attrFn ) { + return jQuery( elem )[ name ]( value ); + } + + // Fallback to prop when attributes are not supported + if ( typeof elem.getAttribute === "undefined" ) { + return jQuery.prop( elem, name, value ); + } + + notxml = nType !== 1 || !jQuery.isXMLDoc( elem ); + + // All attributes are lowercase + // Grab necessary hook if one is defined + if ( notxml ) { + name = name.toLowerCase(); + hooks = jQuery.attrHooks[ name ] || ( rboolean.test( name ) ? boolHook : nodeHook ); + } + + if ( value !== undefined ) { + + if ( value === null ) { + jQuery.removeAttr( elem, name ); + return; + + } else if ( hooks && "set" in hooks && notxml && (ret = hooks.set( elem, value, name )) !== undefined ) { + return ret; + + } else { + elem.setAttribute( name, "" + value ); + return value; + } + + } else if ( hooks && "get" in hooks && notxml && (ret = hooks.get( elem, name )) !== null ) { + return ret; + + } else { + + ret = elem.getAttribute( name ); + + // Non-existent attributes return null, we normalize to undefined + return ret === null ? + undefined : + ret; + } + }, + + removeAttr: function( elem, value ) { + var propName, attrNames, name, l, isBool, + i = 0; + + if ( value && elem.nodeType === 1 ) { + attrNames = value.toLowerCase().split( rspace ); + l = attrNames.length; + + for ( ; i < l; i++ ) { + name = attrNames[ i ]; + + if ( name ) { + propName = jQuery.propFix[ name ] || name; + isBool = rboolean.test( name ); + + // See #9699 for explanation of this approach (setting first, then removal) + // Do not do this for boolean attributes (see #10870) + if ( !isBool ) { + jQuery.attr( elem, name, "" ); + } + elem.removeAttribute( getSetAttribute ? name : propName ); + + // Set corresponding property to false for boolean attributes + if ( isBool && propName in elem ) { + elem[ propName ] = false; + } + } + } + } + }, + + attrHooks: { + type: { + set: function( elem, value ) { + // We can't allow the type property to be changed (since it causes problems in IE) + if ( rtype.test( elem.nodeName ) && elem.parentNode ) { + jQuery.error( "type property can't be changed" ); + } else if ( !jQuery.support.radioValue && value === "radio" && jQuery.nodeName(elem, "input") ) { + // Setting the type on a radio button after the value resets the value in IE6-9 + // Reset value to it's default in case type is set after value + // This is for element creation + var val = elem.value; + elem.setAttribute( "type", value ); + if ( val ) { + elem.value = val; + } + return value; + } + } + }, + // Use the value property for back compat + // Use the nodeHook for button elements in IE6/7 (#1954) + value: { + get: function( elem, name ) { + if ( nodeHook && jQuery.nodeName( elem, "button" ) ) { + return nodeHook.get( elem, name ); + } + return name in elem ? + elem.value : + null; + }, + set: function( elem, value, name ) { + if ( nodeHook && jQuery.nodeName( elem, "button" ) ) { + return nodeHook.set( elem, value, name ); + } + // Does not return so that setAttribute is also used + elem.value = value; + } + } + }, + + propFix: { + tabindex: "tabIndex", + readonly: "readOnly", + "for": "htmlFor", + "class": "className", + maxlength: "maxLength", + cellspacing: "cellSpacing", + cellpadding: "cellPadding", + rowspan: "rowSpan", + colspan: "colSpan", + usemap: "useMap", + frameborder: "frameBorder", + contenteditable: "contentEditable" + }, + + prop: function( elem, name, value ) { + var ret, hooks, notxml, + nType = elem.nodeType; + + // don't get/set properties on text, comment and attribute nodes + if ( !elem || nType === 3 || nType === 8 || nType === 2 ) { + return; + } + + notxml = nType !== 1 || !jQuery.isXMLDoc( elem ); + + if ( notxml ) { + // Fix name and attach hooks + name = jQuery.propFix[ name ] || name; + hooks = jQuery.propHooks[ name ]; + } + + if ( value !== undefined ) { + if ( hooks && "set" in hooks && (ret = hooks.set( elem, value, name )) !== undefined ) { + return ret; + + } else { + return ( elem[ name ] = value ); + } + + } else { + if ( hooks && "get" in hooks && (ret = hooks.get( elem, name )) !== null ) { + return ret; + + } else { + return elem[ name ]; + } + } + }, + + propHooks: { + tabIndex: { + get: function( elem ) { + // elem.tabIndex doesn't always return the correct value when it hasn't been explicitly set + // http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/ + var attributeNode = elem.getAttributeNode("tabindex"); + + return attributeNode && attributeNode.specified ? + parseInt( attributeNode.value, 10 ) : + rfocusable.test( elem.nodeName ) || rclickable.test( elem.nodeName ) && elem.href ? + 0 : + undefined; + } + } + } +}); + +// Add the tabIndex propHook to attrHooks for back-compat (different case is intentional) +jQuery.attrHooks.tabindex = jQuery.propHooks.tabIndex; + +// Hook for boolean attributes +boolHook = { + get: function( elem, name ) { + // Align boolean attributes with corresponding properties + // Fall back to attribute presence where some booleans are not supported + var attrNode, + property = jQuery.prop( elem, name ); + return property === true || typeof property !== "boolean" && ( attrNode = elem.getAttributeNode(name) ) && attrNode.nodeValue !== false ? + name.toLowerCase() : + undefined; + }, + set: function( elem, value, name ) { + var propName; + if ( value === false ) { + // Remove boolean attributes when set to false + jQuery.removeAttr( elem, name ); + } else { + // value is true since we know at this point it's type boolean and not false + // Set boolean attributes to the same name and set the DOM property + propName = jQuery.propFix[ name ] || name; + if ( propName in elem ) { + // Only set the IDL specifically if it already exists on the element + elem[ propName ] = true; + } + + elem.setAttribute( name, name.toLowerCase() ); + } + return name; + } +}; + +// IE6/7 do not support getting/setting some attributes with get/setAttribute +if ( !getSetAttribute ) { + + fixSpecified = { + name: true, + id: true, + coords: true + }; + + // Use this for any attribute in IE6/7 + // This fixes almost every IE6/7 issue + nodeHook = jQuery.valHooks.button = { + get: function( elem, name ) { + var ret; + ret = elem.getAttributeNode( name ); + return ret && ( fixSpecified[ name ] ? ret.nodeValue !== "" : ret.specified ) ? + ret.nodeValue : + undefined; + }, + set: function( elem, value, name ) { + // Set the existing or create a new attribute node + var ret = elem.getAttributeNode( name ); + if ( !ret ) { + ret = document.createAttribute( name ); + elem.setAttributeNode( ret ); + } + return ( ret.nodeValue = value + "" ); + } + }; + + // Apply the nodeHook to tabindex + jQuery.attrHooks.tabindex.set = nodeHook.set; + + // Set width and height to auto instead of 0 on empty string( Bug #8150 ) + // This is for removals + jQuery.each([ "width", "height" ], function( i, name ) { + jQuery.attrHooks[ name ] = jQuery.extend( jQuery.attrHooks[ name ], { + set: function( elem, value ) { + if ( value === "" ) { + elem.setAttribute( name, "auto" ); + return value; + } + } + }); + }); + + // Set contenteditable to false on removals(#10429) + // Setting to empty string throws an error as an invalid value + jQuery.attrHooks.contenteditable = { + get: nodeHook.get, + set: function( elem, value, name ) { + if ( value === "" ) { + value = "false"; + } + nodeHook.set( elem, value, name ); + } + }; +} + + +// Some attributes require a special call on IE +if ( !jQuery.support.hrefNormalized ) { + jQuery.each([ "href", "src", "width", "height" ], function( i, name ) { + jQuery.attrHooks[ name ] = jQuery.extend( jQuery.attrHooks[ name ], { + get: function( elem ) { + var ret = elem.getAttribute( name, 2 ); + return ret === null ? undefined : ret; + } + }); + }); +} + +if ( !jQuery.support.style ) { + jQuery.attrHooks.style = { + get: function( elem ) { + // Return undefined in the case of empty string + // Normalize to lowercase since IE uppercases css property names + return elem.style.cssText.toLowerCase() || undefined; + }, + set: function( elem, value ) { + return ( elem.style.cssText = "" + value ); + } + }; +} + +// Safari mis-reports the default selected property of an option +// Accessing the parent's selectedIndex property fixes it +if ( !jQuery.support.optSelected ) { + jQuery.propHooks.selected = jQuery.extend( jQuery.propHooks.selected, { + get: function( elem ) { + var parent = elem.parentNode; + + if ( parent ) { + parent.selectedIndex; + + // Make sure that it also works with optgroups, see #5701 + if ( parent.parentNode ) { + parent.parentNode.selectedIndex; + } + } + return null; + } + }); +} + +// IE6/7 call enctype encoding +if ( !jQuery.support.enctype ) { + jQuery.propFix.enctype = "encoding"; +} + +// Radios and checkboxes getter/setter +if ( !jQuery.support.checkOn ) { + jQuery.each([ "radio", "checkbox" ], function() { + jQuery.valHooks[ this ] = { + get: function( elem ) { + // Handle the case where in Webkit "" is returned instead of "on" if a value isn't specified + return elem.getAttribute("value") === null ? "on" : elem.value; + } + }; + }); +} +jQuery.each([ "radio", "checkbox" ], function() { + jQuery.valHooks[ this ] = jQuery.extend( jQuery.valHooks[ this ], { + set: function( elem, value ) { + if ( jQuery.isArray( value ) ) { + return ( elem.checked = jQuery.inArray( jQuery(elem).val(), value ) >= 0 ); + } + } + }); +}); + + + + +var rformElems = /^(?:textarea|input|select)$/i, + rtypenamespace = /^([^\.]*)?(?:\.(.+))?$/, + rhoverHack = /(?:^|\s)hover(\.\S+)?\b/, + rkeyEvent = /^key/, + rmouseEvent = /^(?:mouse|contextmenu)|click/, + rfocusMorph = /^(?:focusinfocus|focusoutblur)$/, + rquickIs = /^(\w*)(?:#([\w\-]+))?(?:\.([\w\-]+))?$/, + quickParse = function( selector ) { + var quick = rquickIs.exec( selector ); + if ( quick ) { + // 0 1 2 3 + // [ _, tag, id, class ] + quick[1] = ( quick[1] || "" ).toLowerCase(); + quick[3] = quick[3] && new RegExp( "(?:^|\\s)" + quick[3] + "(?:\\s|$)" ); + } + return quick; + }, + quickIs = function( elem, m ) { + var attrs = elem.attributes || {}; + return ( + (!m[1] || elem.nodeName.toLowerCase() === m[1]) && + (!m[2] || (attrs.id || {}).value === m[2]) && + (!m[3] || m[3].test( (attrs[ "class" ] || {}).value )) + ); + }, + hoverHack = function( events ) { + return jQuery.event.special.hover ? events : events.replace( rhoverHack, "mouseenter$1 mouseleave$1" ); + }; + +/* + * Helper functions for managing events -- not part of the public interface. + * Props to Dean Edwards' addEvent library for many of the ideas. + */ +jQuery.event = { + + add: function( elem, types, handler, data, selector ) { + + var elemData, eventHandle, events, + t, tns, type, namespaces, handleObj, + handleObjIn, quick, handlers, special; + + // Don't attach events to noData or text/comment nodes (allow plain objects tho) + if ( elem.nodeType === 3 || elem.nodeType === 8 || !types || !handler || !(elemData = jQuery._data( elem )) ) { + return; + } + + // Caller can pass in an object of custom data in lieu of the handler + if ( handler.handler ) { + handleObjIn = handler; + handler = handleObjIn.handler; + selector = handleObjIn.selector; + } + + // Make sure that the handler has a unique ID, used to find/remove it later + if ( !handler.guid ) { + handler.guid = jQuery.guid++; + } + + // Init the element's event structure and main handler, if this is the first + events = elemData.events; + if ( !events ) { + elemData.events = events = {}; + } + eventHandle = elemData.handle; + if ( !eventHandle ) { + elemData.handle = eventHandle = function( e ) { + // Discard the second event of a jQuery.event.trigger() and + // when an event is called after a page has unloaded + return typeof jQuery !== "undefined" && (!e || jQuery.event.triggered !== e.type) ? + jQuery.event.dispatch.apply( eventHandle.elem, arguments ) : + undefined; + }; + // Add elem as a property of the handle fn to prevent a memory leak with IE non-native events + eventHandle.elem = elem; + } + + // Handle multiple events separated by a space + // jQuery(...).bind("mouseover mouseout", fn); + types = jQuery.trim( hoverHack(types) ).split( " " ); + for ( t = 0; t < types.length; t++ ) { + + tns = rtypenamespace.exec( types[t] ) || []; + type = tns[1]; + namespaces = ( tns[2] || "" ).split( "." ).sort(); + + // If event changes its type, use the special event handlers for the changed type + special = jQuery.event.special[ type ] || {}; + + // If selector defined, determine special event api type, otherwise given type + type = ( selector ? special.delegateType : special.bindType ) || type; + + // Update special based on newly reset type + special = jQuery.event.special[ type ] || {}; + + // handleObj is passed to all event handlers + handleObj = jQuery.extend({ + type: type, + origType: tns[1], + data: data, + handler: handler, + guid: handler.guid, + selector: selector, + quick: selector && quickParse( selector ), + namespace: namespaces.join(".") + }, handleObjIn ); + + // Init the event handler queue if we're the first + handlers = events[ type ]; + if ( !handlers ) { + handlers = events[ type ] = []; + handlers.delegateCount = 0; + + // Only use addEventListener/attachEvent if the special events handler returns false + if ( !special.setup || special.setup.call( elem, data, namespaces, eventHandle ) === false ) { + // Bind the global event handler to the element + if ( elem.addEventListener ) { + elem.addEventListener( type, eventHandle, false ); + + } else if ( elem.attachEvent ) { + elem.attachEvent( "on" + type, eventHandle ); + } + } + } + + if ( special.add ) { + special.add.call( elem, handleObj ); + + if ( !handleObj.handler.guid ) { + handleObj.handler.guid = handler.guid; + } + } + + // Add to the element's handler list, delegates in front + if ( selector ) { + handlers.splice( handlers.delegateCount++, 0, handleObj ); + } else { + handlers.push( handleObj ); + } + + // Keep track of which events have ever been used, for event optimization + jQuery.event.global[ type ] = true; + } + + // Nullify elem to prevent memory leaks in IE + elem = null; + }, + + global: {}, + + // Detach an event or set of events from an element + remove: function( elem, types, handler, selector, mappedTypes ) { + + var elemData = jQuery.hasData( elem ) && jQuery._data( elem ), + t, tns, type, origType, namespaces, origCount, + j, events, special, handle, eventType, handleObj; + + if ( !elemData || !(events = elemData.events) ) { + return; + } + + // Once for each type.namespace in types; type may be omitted + types = jQuery.trim( hoverHack( types || "" ) ).split(" "); + for ( t = 0; t < types.length; t++ ) { + tns = rtypenamespace.exec( types[t] ) || []; + type = origType = tns[1]; + namespaces = tns[2]; + + // Unbind all events (on this namespace, if provided) for the element + if ( !type ) { + for ( type in events ) { + jQuery.event.remove( elem, type + types[ t ], handler, selector, true ); + } + continue; + } + + special = jQuery.event.special[ type ] || {}; + type = ( selector? special.delegateType : special.bindType ) || type; + eventType = events[ type ] || []; + origCount = eventType.length; + namespaces = namespaces ? new RegExp("(^|\\.)" + namespaces.split(".").sort().join("\\.(?:.*\\.)?") + "(\\.|$)") : null; + + // Remove matching events + for ( j = 0; j < eventType.length; j++ ) { + handleObj = eventType[ j ]; + + if ( ( mappedTypes || origType === handleObj.origType ) && + ( !handler || handler.guid === handleObj.guid ) && + ( !namespaces || namespaces.test( handleObj.namespace ) ) && + ( !selector || selector === handleObj.selector || selector === "**" && handleObj.selector ) ) { + eventType.splice( j--, 1 ); + + if ( handleObj.selector ) { + eventType.delegateCount--; + } + if ( special.remove ) { + special.remove.call( elem, handleObj ); + } + } + } + + // Remove generic event handler if we removed something and no more handlers exist + // (avoids potential for endless recursion during removal of special event handlers) + if ( eventType.length === 0 && origCount !== eventType.length ) { + if ( !special.teardown || special.teardown.call( elem, namespaces ) === false ) { + jQuery.removeEvent( elem, type, elemData.handle ); + } + + delete events[ type ]; + } + } + + // Remove the expando if it's no longer used + if ( jQuery.isEmptyObject( events ) ) { + handle = elemData.handle; + if ( handle ) { + handle.elem = null; + } + + // removeData also checks for emptiness and clears the expando if empty + // so use it instead of delete + jQuery.removeData( elem, [ "events", "handle" ], true ); + } + }, + + // Events that are safe to short-circuit if no handlers are attached. + // Native DOM events should not be added, they may have inline handlers. + customEvent: { + "getData": true, + "setData": true, + "changeData": true + }, + + trigger: function( event, data, elem, onlyHandlers ) { + // Don't do events on text and comment nodes + if ( elem && (elem.nodeType === 3 || elem.nodeType === 8) ) { + return; + } + + // Event object or event type + var type = event.type || event, + namespaces = [], + cache, exclusive, i, cur, old, ontype, special, handle, eventPath, bubbleType; + + // focus/blur morphs to focusin/out; ensure we're not firing them right now + if ( rfocusMorph.test( type + jQuery.event.triggered ) ) { + return; + } + + if ( type.indexOf( "!" ) >= 0 ) { + // Exclusive events trigger only for the exact event (no namespaces) + type = type.slice(0, -1); + exclusive = true; + } + + if ( type.indexOf( "." ) >= 0 ) { + // Namespaced trigger; create a regexp to match event type in handle() + namespaces = type.split("."); + type = namespaces.shift(); + namespaces.sort(); + } + + if ( (!elem || jQuery.event.customEvent[ type ]) && !jQuery.event.global[ type ] ) { + // No jQuery handlers for this event type, and it can't have inline handlers + return; + } + + // Caller can pass in an Event, Object, or just an event type string + event = typeof event === "object" ? + // jQuery.Event object + event[ jQuery.expando ] ? event : + // Object literal + new jQuery.Event( type, event ) : + // Just the event type (string) + new jQuery.Event( type ); + + event.type = type; + event.isTrigger = true; + event.exclusive = exclusive; + event.namespace = namespaces.join( "." ); + event.namespace_re = event.namespace? new RegExp("(^|\\.)" + namespaces.join("\\.(?:.*\\.)?") + "(\\.|$)") : null; + ontype = type.indexOf( ":" ) < 0 ? "on" + type : ""; + + // Handle a global trigger + if ( !elem ) { + + // TODO: Stop taunting the data cache; remove global events and always attach to document + cache = jQuery.cache; + for ( i in cache ) { + if ( cache[ i ].events && cache[ i ].events[ type ] ) { + jQuery.event.trigger( event, data, cache[ i ].handle.elem, true ); + } + } + return; + } + + // Clean up the event in case it is being reused + event.result = undefined; + if ( !event.target ) { + event.target = elem; + } + + // Clone any incoming data and prepend the event, creating the handler arg list + data = data != null ? jQuery.makeArray( data ) : []; + data.unshift( event ); + + // Allow special events to draw outside the lines + special = jQuery.event.special[ type ] || {}; + if ( special.trigger && special.trigger.apply( elem, data ) === false ) { + return; + } + + // Determine event propagation path in advance, per W3C events spec (#9951) + // Bubble up to document, then to window; watch for a global ownerDocument var (#9724) + eventPath = [[ elem, special.bindType || type ]]; + if ( !onlyHandlers && !special.noBubble && !jQuery.isWindow( elem ) ) { + + bubbleType = special.delegateType || type; + cur = rfocusMorph.test( bubbleType + type ) ? elem : elem.parentNode; + old = null; + for ( ; cur; cur = cur.parentNode ) { + eventPath.push([ cur, bubbleType ]); + old = cur; + } + + // Only add window if we got to document (e.g., not plain obj or detached DOM) + if ( old && old === elem.ownerDocument ) { + eventPath.push([ old.defaultView || old.parentWindow || window, bubbleType ]); + } + } + + // Fire handlers on the event path + for ( i = 0; i < eventPath.length && !event.isPropagationStopped(); i++ ) { + + cur = eventPath[i][0]; + event.type = eventPath[i][1]; + + handle = ( jQuery._data( cur, "events" ) || {} )[ event.type ] && jQuery._data( cur, "handle" ); + if ( handle ) { + handle.apply( cur, data ); + } + // Note that this is a bare JS function and not a jQuery handler + handle = ontype && cur[ ontype ]; + if ( handle && jQuery.acceptData( cur ) && handle.apply( cur, data ) === false ) { + event.preventDefault(); + } + } + event.type = type; + + // If nobody prevented the default action, do it now + if ( !onlyHandlers && !event.isDefaultPrevented() ) { + + if ( (!special._default || special._default.apply( elem.ownerDocument, data ) === false) && + !(type === "click" && jQuery.nodeName( elem, "a" )) && jQuery.acceptData( elem ) ) { + + // Call a native DOM method on the target with the same name name as the event. + // Can't use an .isFunction() check here because IE6/7 fails that test. + // Don't do default actions on window, that's where global variables be (#6170) + // IE<9 dies on focus/blur to hidden element (#1486) + if ( ontype && elem[ type ] && ((type !== "focus" && type !== "blur") || event.target.offsetWidth !== 0) && !jQuery.isWindow( elem ) ) { + + // Don't re-trigger an onFOO event when we call its FOO() method + old = elem[ ontype ]; + + if ( old ) { + elem[ ontype ] = null; + } + + // Prevent re-triggering of the same event, since we already bubbled it above + jQuery.event.triggered = type; + elem[ type ](); + jQuery.event.triggered = undefined; + + if ( old ) { + elem[ ontype ] = old; + } + } + } + } + + return event.result; + }, + + dispatch: function( event ) { + + // Make a writable jQuery.Event from the native event object + event = jQuery.event.fix( event || window.event ); + + var handlers = ( (jQuery._data( this, "events" ) || {} )[ event.type ] || []), + delegateCount = handlers.delegateCount, + args = [].slice.call( arguments, 0 ), + run_all = !event.exclusive && !event.namespace, + special = jQuery.event.special[ event.type ] || {}, + handlerQueue = [], + i, j, cur, jqcur, ret, selMatch, matched, matches, handleObj, sel, related; + + // Use the fix-ed jQuery.Event rather than the (read-only) native event + args[0] = event; + event.delegateTarget = this; + + // Call the preDispatch hook for the mapped type, and let it bail if desired + if ( special.preDispatch && special.preDispatch.call( this, event ) === false ) { + return; + } + + // Determine handlers that should run if there are delegated events + // Avoid non-left-click bubbling in Firefox (#3861) + if ( delegateCount && !(event.button && event.type === "click") ) { + + // Pregenerate a single jQuery object for reuse with .is() + jqcur = jQuery(this); + jqcur.context = this.ownerDocument || this; + + for ( cur = event.target; cur != this; cur = cur.parentNode || this ) { + + // Don't process events on disabled elements (#6911, #8165) + if ( cur.disabled !== true ) { + selMatch = {}; + matches = []; + jqcur[0] = cur; + for ( i = 0; i < delegateCount; i++ ) { + handleObj = handlers[ i ]; + sel = handleObj.selector; + + if ( selMatch[ sel ] === undefined ) { + selMatch[ sel ] = ( + handleObj.quick ? quickIs( cur, handleObj.quick ) : jqcur.is( sel ) + ); + } + if ( selMatch[ sel ] ) { + matches.push( handleObj ); + } + } + if ( matches.length ) { + handlerQueue.push({ elem: cur, matches: matches }); + } + } + } + } + + // Add the remaining (directly-bound) handlers + if ( handlers.length > delegateCount ) { + handlerQueue.push({ elem: this, matches: handlers.slice( delegateCount ) }); + } + + // Run delegates first; they may want to stop propagation beneath us + for ( i = 0; i < handlerQueue.length && !event.isPropagationStopped(); i++ ) { + matched = handlerQueue[ i ]; + event.currentTarget = matched.elem; + + for ( j = 0; j < matched.matches.length && !event.isImmediatePropagationStopped(); j++ ) { + handleObj = matched.matches[ j ]; + + // Triggered event must either 1) be non-exclusive and have no namespace, or + // 2) have namespace(s) a subset or equal to those in the bound event (both can have no namespace). + if ( run_all || (!event.namespace && !handleObj.namespace) || event.namespace_re && event.namespace_re.test( handleObj.namespace ) ) { + + event.data = handleObj.data; + event.handleObj = handleObj; + + ret = ( (jQuery.event.special[ handleObj.origType ] || {}).handle || handleObj.handler ) + .apply( matched.elem, args ); + + if ( ret !== undefined ) { + event.result = ret; + if ( ret === false ) { + event.preventDefault(); + event.stopPropagation(); + } + } + } + } + } + + // Call the postDispatch hook for the mapped type + if ( special.postDispatch ) { + special.postDispatch.call( this, event ); + } + + return event.result; + }, + + // Includes some event props shared by KeyEvent and MouseEvent + // *** attrChange attrName relatedNode srcElement are not normalized, non-W3C, deprecated, will be removed in 1.8 *** + props: "attrChange attrName relatedNode srcElement altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "), + + fixHooks: {}, + + keyHooks: { + props: "char charCode key keyCode".split(" "), + filter: function( event, original ) { + + // Add which for key events + if ( event.which == null ) { + event.which = original.charCode != null ? original.charCode : original.keyCode; + } + + return event; + } + }, + + mouseHooks: { + props: "button buttons clientX clientY fromElement offsetX offsetY pageX pageY screenX screenY toElement".split(" "), + filter: function( event, original ) { + var eventDoc, doc, body, + button = original.button, + fromElement = original.fromElement; + + // Calculate pageX/Y if missing and clientX/Y available + if ( event.pageX == null && original.clientX != null ) { + eventDoc = event.target.ownerDocument || document; + doc = eventDoc.documentElement; + body = eventDoc.body; + + event.pageX = original.clientX + ( doc && doc.scrollLeft || body && body.scrollLeft || 0 ) - ( doc && doc.clientLeft || body && body.clientLeft || 0 ); + event.pageY = original.clientY + ( doc && doc.scrollTop || body && body.scrollTop || 0 ) - ( doc && doc.clientTop || body && body.clientTop || 0 ); + } + + // Add relatedTarget, if necessary + if ( !event.relatedTarget && fromElement ) { + event.relatedTarget = fromElement === event.target ? original.toElement : fromElement; + } + + // Add which for click: 1 === left; 2 === middle; 3 === right + // Note: button is not normalized, so don't use it + if ( !event.which && button !== undefined ) { + event.which = ( button & 1 ? 1 : ( button & 2 ? 3 : ( button & 4 ? 2 : 0 ) ) ); + } + + return event; + } + }, + + fix: function( event ) { + if ( event[ jQuery.expando ] ) { + return event; + } + + // Create a writable copy of the event object and normalize some properties + var i, prop, + originalEvent = event, + fixHook = jQuery.event.fixHooks[ event.type ] || {}, + copy = fixHook.props ? this.props.concat( fixHook.props ) : this.props; + + event = jQuery.Event( originalEvent ); + + for ( i = copy.length; i; ) { + prop = copy[ --i ]; + event[ prop ] = originalEvent[ prop ]; + } + + // Fix target property, if necessary (#1925, IE 6/7/8 & Safari2) + if ( !event.target ) { + event.target = originalEvent.srcElement || document; + } + + // Target should not be a text node (#504, Safari) + if ( event.target.nodeType === 3 ) { + event.target = event.target.parentNode; + } + + // For mouse/key events; add metaKey if it's not there (#3368, IE6/7/8) + if ( event.metaKey === undefined ) { + event.metaKey = event.ctrlKey; + } + + return fixHook.filter? fixHook.filter( event, originalEvent ) : event; + }, + + special: { + ready: { + // Make sure the ready event is setup + setup: jQuery.bindReady + }, + + load: { + // Prevent triggered image.load events from bubbling to window.load + noBubble: true + }, + + focus: { + delegateType: "focusin" + }, + blur: { + delegateType: "focusout" + }, + + beforeunload: { + setup: function( data, namespaces, eventHandle ) { + // We only want to do this special case on windows + if ( jQuery.isWindow( this ) ) { + this.onbeforeunload = eventHandle; + } + }, + + teardown: function( namespaces, eventHandle ) { + if ( this.onbeforeunload === eventHandle ) { + this.onbeforeunload = null; + } + } + } + }, + + simulate: function( type, elem, event, bubble ) { + // Piggyback on a donor event to simulate a different one. + // Fake originalEvent to avoid donor's stopPropagation, but if the + // simulated event prevents default then we do the same on the donor. + var e = jQuery.extend( + new jQuery.Event(), + event, + { type: type, + isSimulated: true, + originalEvent: {} + } + ); + if ( bubble ) { + jQuery.event.trigger( e, null, elem ); + } else { + jQuery.event.dispatch.call( elem, e ); + } + if ( e.isDefaultPrevented() ) { + event.preventDefault(); + } + } +}; + +// Some plugins are using, but it's undocumented/deprecated and will be removed. +// The 1.7 special event interface should provide all the hooks needed now. +jQuery.event.handle = jQuery.event.dispatch; + +jQuery.removeEvent = document.removeEventListener ? + function( elem, type, handle ) { + if ( elem.removeEventListener ) { + elem.removeEventListener( type, handle, false ); + } + } : + function( elem, type, handle ) { + if ( elem.detachEvent ) { + elem.detachEvent( "on" + type, handle ); + } + }; + +jQuery.Event = function( src, props ) { + // Allow instantiation without the 'new' keyword + if ( !(this instanceof jQuery.Event) ) { + return new jQuery.Event( src, props ); + } + + // Event object + if ( src && src.type ) { + this.originalEvent = src; + this.type = src.type; + + // Events bubbling up the document may have been marked as prevented + // by a handler lower down the tree; reflect the correct value. + this.isDefaultPrevented = ( src.defaultPrevented || src.returnValue === false || + src.getPreventDefault && src.getPreventDefault() ) ? returnTrue : returnFalse; + + // Event type + } else { + this.type = src; + } + + // Put explicitly provided properties onto the event object + if ( props ) { + jQuery.extend( this, props ); + } + + // Create a timestamp if incoming event doesn't have one + this.timeStamp = src && src.timeStamp || jQuery.now(); + + // Mark it as fixed + this[ jQuery.expando ] = true; +}; + +function returnFalse() { + return false; +} +function returnTrue() { + return true; +} + +// jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding +// http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html +jQuery.Event.prototype = { + preventDefault: function() { + this.isDefaultPrevented = returnTrue; + + var e = this.originalEvent; + if ( !e ) { + return; + } + + // if preventDefault exists run it on the original event + if ( e.preventDefault ) { + e.preventDefault(); + + // otherwise set the returnValue property of the original event to false (IE) + } else { + e.returnValue = false; + } + }, + stopPropagation: function() { + this.isPropagationStopped = returnTrue; + + var e = this.originalEvent; + if ( !e ) { + return; + } + // if stopPropagation exists run it on the original event + if ( e.stopPropagation ) { + e.stopPropagation(); + } + // otherwise set the cancelBubble property of the original event to true (IE) + e.cancelBubble = true; + }, + stopImmediatePropagation: function() { + this.isImmediatePropagationStopped = returnTrue; + this.stopPropagation(); + }, + isDefaultPrevented: returnFalse, + isPropagationStopped: returnFalse, + isImmediatePropagationStopped: returnFalse +}; + +// Create mouseenter/leave events using mouseover/out and event-time checks +jQuery.each({ + mouseenter: "mouseover", + mouseleave: "mouseout" +}, function( orig, fix ) { + jQuery.event.special[ orig ] = { + delegateType: fix, + bindType: fix, + + handle: function( event ) { + var target = this, + related = event.relatedTarget, + handleObj = event.handleObj, + selector = handleObj.selector, + ret; + + // For mousenter/leave call the handler if related is outside the target. + // NB: No relatedTarget if the mouse left/entered the browser window + if ( !related || (related !== target && !jQuery.contains( target, related )) ) { + event.type = handleObj.origType; + ret = handleObj.handler.apply( this, arguments ); + event.type = fix; + } + return ret; + } + }; +}); + +// IE submit delegation +if ( !jQuery.support.submitBubbles ) { + + jQuery.event.special.submit = { + setup: function() { + // Only need this for delegated form submit events + if ( jQuery.nodeName( this, "form" ) ) { + return false; + } + + // Lazy-add a submit handler when a descendant form may potentially be submitted + jQuery.event.add( this, "click._submit keypress._submit", function( e ) { + // Node name check avoids a VML-related crash in IE (#9807) + var elem = e.target, + form = jQuery.nodeName( elem, "input" ) || jQuery.nodeName( elem, "button" ) ? elem.form : undefined; + if ( form && !form._submit_attached ) { + jQuery.event.add( form, "submit._submit", function( event ) { + event._submit_bubble = true; + }); + form._submit_attached = true; + } + }); + // return undefined since we don't need an event listener + }, + + postDispatch: function( event ) { + // If form was submitted by the user, bubble the event up the tree + if ( event._submit_bubble ) { + delete event._submit_bubble; + if ( this.parentNode && !event.isTrigger ) { + jQuery.event.simulate( "submit", this.parentNode, event, true ); + } + } + }, + + teardown: function() { + // Only need this for delegated form submit events + if ( jQuery.nodeName( this, "form" ) ) { + return false; + } + + // Remove delegated handlers; cleanData eventually reaps submit handlers attached above + jQuery.event.remove( this, "._submit" ); + } + }; +} + +// IE change delegation and checkbox/radio fix +if ( !jQuery.support.changeBubbles ) { + + jQuery.event.special.change = { + + setup: function() { + + if ( rformElems.test( this.nodeName ) ) { + // IE doesn't fire change on a check/radio until blur; trigger it on click + // after a propertychange. Eat the blur-change in special.change.handle. + // This still fires onchange a second time for check/radio after blur. + if ( this.type === "checkbox" || this.type === "radio" ) { + jQuery.event.add( this, "propertychange._change", function( event ) { + if ( event.originalEvent.propertyName === "checked" ) { + this._just_changed = true; + } + }); + jQuery.event.add( this, "click._change", function( event ) { + if ( this._just_changed && !event.isTrigger ) { + this._just_changed = false; + jQuery.event.simulate( "change", this, event, true ); + } + }); + } + return false; + } + // Delegated event; lazy-add a change handler on descendant inputs + jQuery.event.add( this, "beforeactivate._change", function( e ) { + var elem = e.target; + + if ( rformElems.test( elem.nodeName ) && !elem._change_attached ) { + jQuery.event.add( elem, "change._change", function( event ) { + if ( this.parentNode && !event.isSimulated && !event.isTrigger ) { + jQuery.event.simulate( "change", this.parentNode, event, true ); + } + }); + elem._change_attached = true; + } + }); + }, + + handle: function( event ) { + var elem = event.target; + + // Swallow native change events from checkbox/radio, we already triggered them above + if ( this !== elem || event.isSimulated || event.isTrigger || (elem.type !== "radio" && elem.type !== "checkbox") ) { + return event.handleObj.handler.apply( this, arguments ); + } + }, + + teardown: function() { + jQuery.event.remove( this, "._change" ); + + return rformElems.test( this.nodeName ); + } + }; +} + +// Create "bubbling" focus and blur events +if ( !jQuery.support.focusinBubbles ) { + jQuery.each({ focus: "focusin", blur: "focusout" }, function( orig, fix ) { + + // Attach a single capturing handler while someone wants focusin/focusout + var attaches = 0, + handler = function( event ) { + jQuery.event.simulate( fix, event.target, jQuery.event.fix( event ), true ); + }; + + jQuery.event.special[ fix ] = { + setup: function() { + if ( attaches++ === 0 ) { + document.addEventListener( orig, handler, true ); + } + }, + teardown: function() { + if ( --attaches === 0 ) { + document.removeEventListener( orig, handler, true ); + } + } + }; + }); +} + +jQuery.fn.extend({ + + on: function( types, selector, data, fn, /*INTERNAL*/ one ) { + var origFn, type; + + // Types can be a map of types/handlers + if ( typeof types === "object" ) { + // ( types-Object, selector, data ) + if ( typeof selector !== "string" ) { // && selector != null + // ( types-Object, data ) + data = data || selector; + selector = undefined; + } + for ( type in types ) { + this.on( type, selector, data, types[ type ], one ); + } + return this; + } + + if ( data == null && fn == null ) { + // ( types, fn ) + fn = selector; + data = selector = undefined; + } else if ( fn == null ) { + if ( typeof selector === "string" ) { + // ( types, selector, fn ) + fn = data; + data = undefined; + } else { + // ( types, data, fn ) + fn = data; + data = selector; + selector = undefined; + } + } + if ( fn === false ) { + fn = returnFalse; + } else if ( !fn ) { + return this; + } + + if ( one === 1 ) { + origFn = fn; + fn = function( event ) { + // Can use an empty set, since event contains the info + jQuery().off( event ); + return origFn.apply( this, arguments ); + }; + // Use same guid so caller can remove using origFn + fn.guid = origFn.guid || ( origFn.guid = jQuery.guid++ ); + } + return this.each( function() { + jQuery.event.add( this, types, fn, data, selector ); + }); + }, + one: function( types, selector, data, fn ) { + return this.on( types, selector, data, fn, 1 ); + }, + off: function( types, selector, fn ) { + if ( types && types.preventDefault && types.handleObj ) { + // ( event ) dispatched jQuery.Event + var handleObj = types.handleObj; + jQuery( types.delegateTarget ).off( + handleObj.namespace ? handleObj.origType + "." + handleObj.namespace : handleObj.origType, + handleObj.selector, + handleObj.handler + ); + return this; + } + if ( typeof types === "object" ) { + // ( types-object [, selector] ) + for ( var type in types ) { + this.off( type, selector, types[ type ] ); + } + return this; + } + if ( selector === false || typeof selector === "function" ) { + // ( types [, fn] ) + fn = selector; + selector = undefined; + } + if ( fn === false ) { + fn = returnFalse; + } + return this.each(function() { + jQuery.event.remove( this, types, fn, selector ); + }); + }, + + bind: function( types, data, fn ) { + return this.on( types, null, data, fn ); + }, + unbind: function( types, fn ) { + return this.off( types, null, fn ); + }, + + live: function( types, data, fn ) { + jQuery( this.context ).on( types, this.selector, data, fn ); + return this; + }, + die: function( types, fn ) { + jQuery( this.context ).off( types, this.selector || "**", fn ); + return this; + }, + + delegate: function( selector, types, data, fn ) { + return this.on( types, selector, data, fn ); + }, + undelegate: function( selector, types, fn ) { + // ( namespace ) or ( selector, types [, fn] ) + return arguments.length == 1? this.off( selector, "**" ) : this.off( types, selector, fn ); + }, + + trigger: function( type, data ) { + return this.each(function() { + jQuery.event.trigger( type, data, this ); + }); + }, + triggerHandler: function( type, data ) { + if ( this[0] ) { + return jQuery.event.trigger( type, data, this[0], true ); + } + }, + + toggle: function( fn ) { + // Save reference to arguments for access in closure + var args = arguments, + guid = fn.guid || jQuery.guid++, + i = 0, + toggler = function( event ) { + // Figure out which function to execute + var lastToggle = ( jQuery._data( this, "lastToggle" + fn.guid ) || 0 ) % i; + jQuery._data( this, "lastToggle" + fn.guid, lastToggle + 1 ); + + // Make sure that clicks stop + event.preventDefault(); + + // and execute the function + return args[ lastToggle ].apply( this, arguments ) || false; + }; + + // link all the functions, so any of them can unbind this click handler + toggler.guid = guid; + while ( i < args.length ) { + args[ i++ ].guid = guid; + } + + return this.click( toggler ); + }, + + hover: function( fnOver, fnOut ) { + return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver ); + } +}); + +jQuery.each( ("blur focus focusin focusout load resize scroll unload click dblclick " + + "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " + + "change select submit keydown keypress keyup error contextmenu").split(" "), function( i, name ) { + + // Handle event binding + jQuery.fn[ name ] = function( data, fn ) { + if ( fn == null ) { + fn = data; + data = null; + } + + return arguments.length > 0 ? + this.on( name, null, data, fn ) : + this.trigger( name ); + }; + + if ( jQuery.attrFn ) { + jQuery.attrFn[ name ] = true; + } + + if ( rkeyEvent.test( name ) ) { + jQuery.event.fixHooks[ name ] = jQuery.event.keyHooks; + } + + if ( rmouseEvent.test( name ) ) { + jQuery.event.fixHooks[ name ] = jQuery.event.mouseHooks; + } +}); + + + +/*! + * Sizzle CSS Selector Engine + * Copyright 2011, The Dojo Foundation + * Released under the MIT, BSD, and GPL Licenses. + * More information: http://sizzlejs.com/ + */ +(function(){ + +var chunker = /((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^\[\]]*\]|['"][^'"]*['"]|[^\[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g, + expando = "sizcache" + (Math.random() + '').replace('.', ''), + done = 0, + toString = Object.prototype.toString, + hasDuplicate = false, + baseHasDuplicate = true, + rBackslash = /\\/g, + rReturn = /\r\n/g, + rNonWord = /\W/; + +// Here we check if the JavaScript engine is using some sort of +// optimization where it does not always call our comparision +// function. If that is the case, discard the hasDuplicate value. +// Thus far that includes Google Chrome. +[0, 0].sort(function() { + baseHasDuplicate = false; + return 0; +}); + +var Sizzle = function( selector, context, results, seed ) { + results = results || []; + context = context || document; + + var origContext = context; + + if ( context.nodeType !== 1 && context.nodeType !== 9 ) { + return []; + } + + if ( !selector || typeof selector !== "string" ) { + return results; + } + + var m, set, checkSet, extra, ret, cur, pop, i, + prune = true, + contextXML = Sizzle.isXML( context ), + parts = [], + soFar = selector; + + // Reset the position of the chunker regexp (start from head) + do { + chunker.exec( "" ); + m = chunker.exec( soFar ); + + if ( m ) { + soFar = m[3]; + + parts.push( m[1] ); + + if ( m[2] ) { + extra = m[3]; + break; + } + } + } while ( m ); + + if ( parts.length > 1 && origPOS.exec( selector ) ) { + + if ( parts.length === 2 && Expr.relative[ parts[0] ] ) { + set = posProcess( parts[0] + parts[1], context, seed ); + + } else { + set = Expr.relative[ parts[0] ] ? + [ context ] : + Sizzle( parts.shift(), context ); + + while ( parts.length ) { + selector = parts.shift(); + + if ( Expr.relative[ selector ] ) { + selector += parts.shift(); + } + + set = posProcess( selector, set, seed ); + } + } + + } else { + // Take a shortcut and set the context if the root selector is an ID + // (but not if it'll be faster if the inner selector is an ID) + if ( !seed && parts.length > 1 && context.nodeType === 9 && !contextXML && + Expr.match.ID.test(parts[0]) && !Expr.match.ID.test(parts[parts.length - 1]) ) { + + ret = Sizzle.find( parts.shift(), context, contextXML ); + context = ret.expr ? + Sizzle.filter( ret.expr, ret.set )[0] : + ret.set[0]; + } + + if ( context ) { + ret = seed ? + { expr: parts.pop(), set: makeArray(seed) } : + Sizzle.find( parts.pop(), parts.length === 1 && (parts[0] === "~" || parts[0] === "+") && context.parentNode ? context.parentNode : context, contextXML ); + + set = ret.expr ? + Sizzle.filter( ret.expr, ret.set ) : + ret.set; + + if ( parts.length > 0 ) { + checkSet = makeArray( set ); + + } else { + prune = false; + } + + while ( parts.length ) { + cur = parts.pop(); + pop = cur; + + if ( !Expr.relative[ cur ] ) { + cur = ""; + } else { + pop = parts.pop(); + } + + if ( pop == null ) { + pop = context; + } + + Expr.relative[ cur ]( checkSet, pop, contextXML ); + } + + } else { + checkSet = parts = []; + } + } + + if ( !checkSet ) { + checkSet = set; + } + + if ( !checkSet ) { + Sizzle.error( cur || selector ); + } + + if ( toString.call(checkSet) === "[object Array]" ) { + if ( !prune ) { + results.push.apply( results, checkSet ); + + } else if ( context && context.nodeType === 1 ) { + for ( i = 0; checkSet[i] != null; i++ ) { + if ( checkSet[i] && (checkSet[i] === true || checkSet[i].nodeType === 1 && Sizzle.contains(context, checkSet[i])) ) { + results.push( set[i] ); + } + } + + } else { + for ( i = 0; checkSet[i] != null; i++ ) { + if ( checkSet[i] && checkSet[i].nodeType === 1 ) { + results.push( set[i] ); + } + } + } + + } else { + makeArray( checkSet, results ); + } + + if ( extra ) { + Sizzle( extra, origContext, results, seed ); + Sizzle.uniqueSort( results ); + } + + return results; +}; + +Sizzle.uniqueSort = function( results ) { + if ( sortOrder ) { + hasDuplicate = baseHasDuplicate; + results.sort( sortOrder ); + + if ( hasDuplicate ) { + for ( var i = 1; i < results.length; i++ ) { + if ( results[i] === results[ i - 1 ] ) { + results.splice( i--, 1 ); + } + } + } + } + + return results; +}; + +Sizzle.matches = function( expr, set ) { + return Sizzle( expr, null, null, set ); +}; + +Sizzle.matchesSelector = function( node, expr ) { + return Sizzle( expr, null, null, [node] ).length > 0; +}; + +Sizzle.find = function( expr, context, isXML ) { + var set, i, len, match, type, left; + + if ( !expr ) { + return []; + } + + for ( i = 0, len = Expr.order.length; i < len; i++ ) { + type = Expr.order[i]; + + if ( (match = Expr.leftMatch[ type ].exec( expr )) ) { + left = match[1]; + match.splice( 1, 1 ); + + if ( left.substr( left.length - 1 ) !== "\\" ) { + match[1] = (match[1] || "").replace( rBackslash, "" ); + set = Expr.find[ type ]( match, context, isXML ); + + if ( set != null ) { + expr = expr.replace( Expr.match[ type ], "" ); + break; + } + } + } + } + + if ( !set ) { + set = typeof context.getElementsByTagName !== "undefined" ? + context.getElementsByTagName( "*" ) : + []; + } + + return { set: set, expr: expr }; +}; + +Sizzle.filter = function( expr, set, inplace, not ) { + var match, anyFound, + type, found, item, filter, left, + i, pass, + old = expr, + result = [], + curLoop = set, + isXMLFilter = set && set[0] && Sizzle.isXML( set[0] ); + + while ( expr && set.length ) { + for ( type in Expr.filter ) { + if ( (match = Expr.leftMatch[ type ].exec( expr )) != null && match[2] ) { + filter = Expr.filter[ type ]; + left = match[1]; + + anyFound = false; + + match.splice(1,1); + + if ( left.substr( left.length - 1 ) === "\\" ) { + continue; + } + + if ( curLoop === result ) { + result = []; + } + + if ( Expr.preFilter[ type ] ) { + match = Expr.preFilter[ type ]( match, curLoop, inplace, result, not, isXMLFilter ); + + if ( !match ) { + anyFound = found = true; + + } else if ( match === true ) { + continue; + } + } + + if ( match ) { + for ( i = 0; (item = curLoop[i]) != null; i++ ) { + if ( item ) { + found = filter( item, match, i, curLoop ); + pass = not ^ found; + + if ( inplace && found != null ) { + if ( pass ) { + anyFound = true; + + } else { + curLoop[i] = false; + } + + } else if ( pass ) { + result.push( item ); + anyFound = true; + } + } + } + } + + if ( found !== undefined ) { + if ( !inplace ) { + curLoop = result; + } + + expr = expr.replace( Expr.match[ type ], "" ); + + if ( !anyFound ) { + return []; + } + + break; + } + } + } + + // Improper expression + if ( expr === old ) { + if ( anyFound == null ) { + Sizzle.error( expr ); + + } else { + break; + } + } + + old = expr; + } + + return curLoop; +}; + +Sizzle.error = function( msg ) { + throw new Error( "Syntax error, unrecognized expression: " + msg ); +}; + +/** + * Utility function for retreiving the text value of an array of DOM nodes + * @param {Array|Element} elem + */ +var getText = Sizzle.getText = function( elem ) { + var i, node, + nodeType = elem.nodeType, + ret = ""; + + if ( nodeType ) { + if ( nodeType === 1 || nodeType === 9 || nodeType === 11 ) { + // Use textContent || innerText for elements + if ( typeof elem.textContent === 'string' ) { + return elem.textContent; + } else if ( typeof elem.innerText === 'string' ) { + // Replace IE's carriage returns + return elem.innerText.replace( rReturn, '' ); + } else { + // Traverse it's children + for ( elem = elem.firstChild; elem; elem = elem.nextSibling) { + ret += getText( elem ); + } + } + } else if ( nodeType === 3 || nodeType === 4 ) { + return elem.nodeValue; + } + } else { + + // If no nodeType, this is expected to be an array + for ( i = 0; (node = elem[i]); i++ ) { + // Do not traverse comment nodes + if ( node.nodeType !== 8 ) { + ret += getText( node ); + } + } + } + return ret; +}; + +var Expr = Sizzle.selectors = { + order: [ "ID", "NAME", "TAG" ], + + match: { + ID: /#((?:[\w\u00c0-\uFFFF\-]|\\.)+)/, + CLASS: /\.((?:[\w\u00c0-\uFFFF\-]|\\.)+)/, + NAME: /\[name=['"]*((?:[\w\u00c0-\uFFFF\-]|\\.)+)['"]*\]/, + ATTR: /\[\s*((?:[\w\u00c0-\uFFFF\-]|\\.)+)\s*(?:(\S?=)\s*(?:(['"])(.*?)\3|(#?(?:[\w\u00c0-\uFFFF\-]|\\.)*)|)|)\s*\]/, + TAG: /^((?:[\w\u00c0-\uFFFF\*\-]|\\.)+)/, + CHILD: /:(only|nth|last|first)-child(?:\(\s*(even|odd|(?:[+\-]?\d+|(?:[+\-]?\d*)?n\s*(?:[+\-]\s*\d+)?))\s*\))?/, + POS: /:(nth|eq|gt|lt|first|last|even|odd)(?:\((\d*)\))?(?=[^\-]|$)/, + PSEUDO: /:((?:[\w\u00c0-\uFFFF\-]|\\.)+)(?:\((['"]?)((?:\([^\)]+\)|[^\(\)]*)+)\2\))?/ + }, + + leftMatch: {}, + + attrMap: { + "class": "className", + "for": "htmlFor" + }, + + attrHandle: { + href: function( elem ) { + return elem.getAttribute( "href" ); + }, + type: function( elem ) { + return elem.getAttribute( "type" ); + } + }, + + relative: { + "+": function(checkSet, part){ + var isPartStr = typeof part === "string", + isTag = isPartStr && !rNonWord.test( part ), + isPartStrNotTag = isPartStr && !isTag; + + if ( isTag ) { + part = part.toLowerCase(); + } + + for ( var i = 0, l = checkSet.length, elem; i < l; i++ ) { + if ( (elem = checkSet[i]) ) { + while ( (elem = elem.previousSibling) && elem.nodeType !== 1 ) {} + + checkSet[i] = isPartStrNotTag || elem && elem.nodeName.toLowerCase() === part ? + elem || false : + elem === part; + } + } + + if ( isPartStrNotTag ) { + Sizzle.filter( part, checkSet, true ); + } + }, + + ">": function( checkSet, part ) { + var elem, + isPartStr = typeof part === "string", + i = 0, + l = checkSet.length; + + if ( isPartStr && !rNonWord.test( part ) ) { + part = part.toLowerCase(); + + for ( ; i < l; i++ ) { + elem = checkSet[i]; + + if ( elem ) { + var parent = elem.parentNode; + checkSet[i] = parent.nodeName.toLowerCase() === part ? parent : false; + } + } + + } else { + for ( ; i < l; i++ ) { + elem = checkSet[i]; + + if ( elem ) { + checkSet[i] = isPartStr ? + elem.parentNode : + elem.parentNode === part; + } + } + + if ( isPartStr ) { + Sizzle.filter( part, checkSet, true ); + } + } + }, + + "": function(checkSet, part, isXML){ + var nodeCheck, + doneName = done++, + checkFn = dirCheck; + + if ( typeof part === "string" && !rNonWord.test( part ) ) { + part = part.toLowerCase(); + nodeCheck = part; + checkFn = dirNodeCheck; + } + + checkFn( "parentNode", part, doneName, checkSet, nodeCheck, isXML ); + }, + + "~": function( checkSet, part, isXML ) { + var nodeCheck, + doneName = done++, + checkFn = dirCheck; + + if ( typeof part === "string" && !rNonWord.test( part ) ) { + part = part.toLowerCase(); + nodeCheck = part; + checkFn = dirNodeCheck; + } + + checkFn( "previousSibling", part, doneName, checkSet, nodeCheck, isXML ); + } + }, + + find: { + ID: function( match, context, isXML ) { + if ( typeof context.getElementById !== "undefined" && !isXML ) { + var m = context.getElementById(match[1]); + // Check parentNode to catch when Blackberry 4.6 returns + // nodes that are no longer in the document #6963 + return m && m.parentNode ? [m] : []; + } + }, + + NAME: function( match, context ) { + if ( typeof context.getElementsByName !== "undefined" ) { + var ret = [], + results = context.getElementsByName( match[1] ); + + for ( var i = 0, l = results.length; i < l; i++ ) { + if ( results[i].getAttribute("name") === match[1] ) { + ret.push( results[i] ); + } + } + + return ret.length === 0 ? null : ret; + } + }, + + TAG: function( match, context ) { + if ( typeof context.getElementsByTagName !== "undefined" ) { + return context.getElementsByTagName( match[1] ); + } + } + }, + preFilter: { + CLASS: function( match, curLoop, inplace, result, not, isXML ) { + match = " " + match[1].replace( rBackslash, "" ) + " "; + + if ( isXML ) { + return match; + } + + for ( var i = 0, elem; (elem = curLoop[i]) != null; i++ ) { + if ( elem ) { + if ( not ^ (elem.className && (" " + elem.className + " ").replace(/[\t\n\r]/g, " ").indexOf(match) >= 0) ) { + if ( !inplace ) { + result.push( elem ); + } + + } else if ( inplace ) { + curLoop[i] = false; + } + } + } + + return false; + }, + + ID: function( match ) { + return match[1].replace( rBackslash, "" ); + }, + + TAG: function( match, curLoop ) { + return match[1].replace( rBackslash, "" ).toLowerCase(); + }, + + CHILD: function( match ) { + if ( match[1] === "nth" ) { + if ( !match[2] ) { + Sizzle.error( match[0] ); + } + + match[2] = match[2].replace(/^\+|\s*/g, ''); + + // parse equations like 'even', 'odd', '5', '2n', '3n+2', '4n-1', '-n+6' + var test = /(-?)(\d*)(?:n([+\-]?\d*))?/.exec( + match[2] === "even" && "2n" || match[2] === "odd" && "2n+1" || + !/\D/.test( match[2] ) && "0n+" + match[2] || match[2]); + + // calculate the numbers (first)n+(last) including if they are negative + match[2] = (test[1] + (test[2] || 1)) - 0; + match[3] = test[3] - 0; + } + else if ( match[2] ) { + Sizzle.error( match[0] ); + } + + // TODO: Move to normal caching system + match[0] = done++; + + return match; + }, + + ATTR: function( match, curLoop, inplace, result, not, isXML ) { + var name = match[1] = match[1].replace( rBackslash, "" ); + + if ( !isXML && Expr.attrMap[name] ) { + match[1] = Expr.attrMap[name]; + } + + // Handle if an un-quoted value was used + match[4] = ( match[4] || match[5] || "" ).replace( rBackslash, "" ); + + if ( match[2] === "~=" ) { + match[4] = " " + match[4] + " "; + } + + return match; + }, + + PSEUDO: function( match, curLoop, inplace, result, not ) { + if ( match[1] === "not" ) { + // If we're dealing with a complex expression, or a simple one + if ( ( chunker.exec(match[3]) || "" ).length > 1 || /^\w/.test(match[3]) ) { + match[3] = Sizzle(match[3], null, null, curLoop); + + } else { + var ret = Sizzle.filter(match[3], curLoop, inplace, true ^ not); + + if ( !inplace ) { + result.push.apply( result, ret ); + } + + return false; + } + + } else if ( Expr.match.POS.test( match[0] ) || Expr.match.CHILD.test( match[0] ) ) { + return true; + } + + return match; + }, + + POS: function( match ) { + match.unshift( true ); + + return match; + } + }, + + filters: { + enabled: function( elem ) { + return elem.disabled === false && elem.type !== "hidden"; + }, + + disabled: function( elem ) { + return elem.disabled === true; + }, + + checked: function( elem ) { + return elem.checked === true; + }, + + selected: function( elem ) { + // Accessing this property makes selected-by-default + // options in Safari work properly + if ( elem.parentNode ) { + elem.parentNode.selectedIndex; + } + + return elem.selected === true; + }, + + parent: function( elem ) { + return !!elem.firstChild; + }, + + empty: function( elem ) { + return !elem.firstChild; + }, + + has: function( elem, i, match ) { + return !!Sizzle( match[3], elem ).length; + }, + + header: function( elem ) { + return (/h\d/i).test( elem.nodeName ); + }, + + text: function( elem ) { + var attr = elem.getAttribute( "type" ), type = elem.type; + // IE6 and 7 will map elem.type to 'text' for new HTML5 types (search, etc) + // use getAttribute instead to test this case + return elem.nodeName.toLowerCase() === "input" && "text" === type && ( attr === type || attr === null ); + }, + + radio: function( elem ) { + return elem.nodeName.toLowerCase() === "input" && "radio" === elem.type; + }, + + checkbox: function( elem ) { + return elem.nodeName.toLowerCase() === "input" && "checkbox" === elem.type; + }, + + file: function( elem ) { + return elem.nodeName.toLowerCase() === "input" && "file" === elem.type; + }, + + password: function( elem ) { + return elem.nodeName.toLowerCase() === "input" && "password" === elem.type; + }, + + submit: function( elem ) { + var name = elem.nodeName.toLowerCase(); + return (name === "input" || name === "button") && "submit" === elem.type; + }, + + image: function( elem ) { + return elem.nodeName.toLowerCase() === "input" && "image" === elem.type; + }, + + reset: function( elem ) { + var name = elem.nodeName.toLowerCase(); + return (name === "input" || name === "button") && "reset" === elem.type; + }, + + button: function( elem ) { + var name = elem.nodeName.toLowerCase(); + return name === "input" && "button" === elem.type || name === "button"; + }, + + input: function( elem ) { + return (/input|select|textarea|button/i).test( elem.nodeName ); + }, + + focus: function( elem ) { + return elem === elem.ownerDocument.activeElement; + } + }, + setFilters: { + first: function( elem, i ) { + return i === 0; + }, + + last: function( elem, i, match, array ) { + return i === array.length - 1; + }, + + even: function( elem, i ) { + return i % 2 === 0; + }, + + odd: function( elem, i ) { + return i % 2 === 1; + }, + + lt: function( elem, i, match ) { + return i < match[3] - 0; + }, + + gt: function( elem, i, match ) { + return i > match[3] - 0; + }, + + nth: function( elem, i, match ) { + return match[3] - 0 === i; + }, + + eq: function( elem, i, match ) { + return match[3] - 0 === i; + } + }, + filter: { + PSEUDO: function( elem, match, i, array ) { + var name = match[1], + filter = Expr.filters[ name ]; + + if ( filter ) { + return filter( elem, i, match, array ); + + } else if ( name === "contains" ) { + return (elem.textContent || elem.innerText || getText([ elem ]) || "").indexOf(match[3]) >= 0; + + } else if ( name === "not" ) { + var not = match[3]; + + for ( var j = 0, l = not.length; j < l; j++ ) { + if ( not[j] === elem ) { + return false; + } + } + + return true; + + } else { + Sizzle.error( name ); + } + }, + + CHILD: function( elem, match ) { + var first, last, + doneName, parent, cache, + count, diff, + type = match[1], + node = elem; + + switch ( type ) { + case "only": + case "first": + while ( (node = node.previousSibling) ) { + if ( node.nodeType === 1 ) { + return false; + } + } + + if ( type === "first" ) { + return true; + } + + node = elem; + + /* falls through */ + case "last": + while ( (node = node.nextSibling) ) { + if ( node.nodeType === 1 ) { + return false; + } + } + + return true; + + case "nth": + first = match[2]; + last = match[3]; + + if ( first === 1 && last === 0 ) { + return true; + } + + doneName = match[0]; + parent = elem.parentNode; + + if ( parent && (parent[ expando ] !== doneName || !elem.nodeIndex) ) { + count = 0; + + for ( node = parent.firstChild; node; node = node.nextSibling ) { + if ( node.nodeType === 1 ) { + node.nodeIndex = ++count; + } + } + + parent[ expando ] = doneName; + } + + diff = elem.nodeIndex - last; + + if ( first === 0 ) { + return diff === 0; + + } else { + return ( diff % first === 0 && diff / first >= 0 ); + } + } + }, + + ID: function( elem, match ) { + return elem.nodeType === 1 && elem.getAttribute("id") === match; + }, + + TAG: function( elem, match ) { + return (match === "*" && elem.nodeType === 1) || !!elem.nodeName && elem.nodeName.toLowerCase() === match; + }, + + CLASS: function( elem, match ) { + return (" " + (elem.className || elem.getAttribute("class")) + " ") + .indexOf( match ) > -1; + }, + + ATTR: function( elem, match ) { + var name = match[1], + result = Sizzle.attr ? + Sizzle.attr( elem, name ) : + Expr.attrHandle[ name ] ? + Expr.attrHandle[ name ]( elem ) : + elem[ name ] != null ? + elem[ name ] : + elem.getAttribute( name ), + value = result + "", + type = match[2], + check = match[4]; + + return result == null ? + type === "!=" : + !type && Sizzle.attr ? + result != null : + type === "=" ? + value === check : + type === "*=" ? + value.indexOf(check) >= 0 : + type === "~=" ? + (" " + value + " ").indexOf(check) >= 0 : + !check ? + value && result !== false : + type === "!=" ? + value !== check : + type === "^=" ? + value.indexOf(check) === 0 : + type === "$=" ? + value.substr(value.length - check.length) === check : + type === "|=" ? + value === check || value.substr(0, check.length + 1) === check + "-" : + false; + }, + + POS: function( elem, match, i, array ) { + var name = match[2], + filter = Expr.setFilters[ name ]; + + if ( filter ) { + return filter( elem, i, match, array ); + } + } + } +}; + +var origPOS = Expr.match.POS, + fescape = function(all, num){ + return "\\" + (num - 0 + 1); + }; + +for ( var type in Expr.match ) { + Expr.match[ type ] = new RegExp( Expr.match[ type ].source + (/(?![^\[]*\])(?![^\(]*\))/.source) ); + Expr.leftMatch[ type ] = new RegExp( /(^(?:.|\r|\n)*?)/.source + Expr.match[ type ].source.replace(/\\(\d+)/g, fescape) ); +} +// Expose origPOS +// "global" as in regardless of relation to brackets/parens +Expr.match.globalPOS = origPOS; + +var makeArray = function( array, results ) { + array = Array.prototype.slice.call( array, 0 ); + + if ( results ) { + results.push.apply( results, array ); + return results; + } + + return array; +}; + +// Perform a simple check to determine if the browser is capable of +// converting a NodeList to an array using builtin methods. +// Also verifies that the returned array holds DOM nodes +// (which is not the case in the Blackberry browser) +try { + Array.prototype.slice.call( document.documentElement.childNodes, 0 )[0].nodeType; + +// Provide a fallback method if it does not work +} catch( e ) { + makeArray = function( array, results ) { + var i = 0, + ret = results || []; + + if ( toString.call(array) === "[object Array]" ) { + Array.prototype.push.apply( ret, array ); + + } else { + if ( typeof array.length === "number" ) { + for ( var l = array.length; i < l; i++ ) { + ret.push( array[i] ); + } + + } else { + for ( ; array[i]; i++ ) { + ret.push( array[i] ); + } + } + } + + return ret; + }; +} + +var sortOrder, siblingCheck; + +if ( document.documentElement.compareDocumentPosition ) { + sortOrder = function( a, b ) { + if ( a === b ) { + hasDuplicate = true; + return 0; + } + + if ( !a.compareDocumentPosition || !b.compareDocumentPosition ) { + return a.compareDocumentPosition ? -1 : 1; + } + + return a.compareDocumentPosition(b) & 4 ? -1 : 1; + }; + +} else { + sortOrder = function( a, b ) { + // The nodes are identical, we can exit early + if ( a === b ) { + hasDuplicate = true; + return 0; + + // Fallback to using sourceIndex (in IE) if it's available on both nodes + } else if ( a.sourceIndex && b.sourceIndex ) { + return a.sourceIndex - b.sourceIndex; + } + + var al, bl, + ap = [], + bp = [], + aup = a.parentNode, + bup = b.parentNode, + cur = aup; + + // If the nodes are siblings (or identical) we can do a quick check + if ( aup === bup ) { + return siblingCheck( a, b ); + + // If no parents were found then the nodes are disconnected + } else if ( !aup ) { + return -1; + + } else if ( !bup ) { + return 1; + } + + // Otherwise they're somewhere else in the tree so we need + // to build up a full list of the parentNodes for comparison + while ( cur ) { + ap.unshift( cur ); + cur = cur.parentNode; + } + + cur = bup; + + while ( cur ) { + bp.unshift( cur ); + cur = cur.parentNode; + } + + al = ap.length; + bl = bp.length; + + // Start walking down the tree looking for a discrepancy + for ( var i = 0; i < al && i < bl; i++ ) { + if ( ap[i] !== bp[i] ) { + return siblingCheck( ap[i], bp[i] ); + } + } + + // We ended someplace up the tree so do a sibling check + return i === al ? + siblingCheck( a, bp[i], -1 ) : + siblingCheck( ap[i], b, 1 ); + }; + + siblingCheck = function( a, b, ret ) { + if ( a === b ) { + return ret; + } + + var cur = a.nextSibling; + + while ( cur ) { + if ( cur === b ) { + return -1; + } + + cur = cur.nextSibling; + } + + return 1; + }; +} + +// Check to see if the browser returns elements by name when +// querying by getElementById (and provide a workaround) +(function(){ + // We're going to inject a fake input element with a specified name + var form = document.createElement("div"), + id = "script" + (new Date()).getTime(), + root = document.documentElement; + + form.innerHTML = ""; + + // Inject it into the root element, check its status, and remove it quickly + root.insertBefore( form, root.firstChild ); + + // The workaround has to do additional checks after a getElementById + // Which slows things down for other browsers (hence the branching) + if ( document.getElementById( id ) ) { + Expr.find.ID = function( match, context, isXML ) { + if ( typeof context.getElementById !== "undefined" && !isXML ) { + var m = context.getElementById(match[1]); + + return m ? + m.id === match[1] || typeof m.getAttributeNode !== "undefined" && m.getAttributeNode("id").nodeValue === match[1] ? + [m] : + undefined : + []; + } + }; + + Expr.filter.ID = function( elem, match ) { + var node = typeof elem.getAttributeNode !== "undefined" && elem.getAttributeNode("id"); + + return elem.nodeType === 1 && node && node.nodeValue === match; + }; + } + + root.removeChild( form ); + + // release memory in IE + root = form = null; +})(); + +(function(){ + // Check to see if the browser returns only elements + // when doing getElementsByTagName("*") + + // Create a fake element + var div = document.createElement("div"); + div.appendChild( document.createComment("") ); + + // Make sure no comments are found + if ( div.getElementsByTagName("*").length > 0 ) { + Expr.find.TAG = function( match, context ) { + var results = context.getElementsByTagName( match[1] ); + + // Filter out possible comments + if ( match[1] === "*" ) { + var tmp = []; + + for ( var i = 0; results[i]; i++ ) { + if ( results[i].nodeType === 1 ) { + tmp.push( results[i] ); + } + } + + results = tmp; + } + + return results; + }; + } + + // Check to see if an attribute returns normalized href attributes + div.innerHTML = ""; + + if ( div.firstChild && typeof div.firstChild.getAttribute !== "undefined" && + div.firstChild.getAttribute("href") !== "#" ) { + + Expr.attrHandle.href = function( elem ) { + return elem.getAttribute( "href", 2 ); + }; + } + + // release memory in IE + div = null; +})(); + +if ( document.querySelectorAll ) { + (function(){ + var oldSizzle = Sizzle, + div = document.createElement("div"), + id = "__sizzle__"; + + div.innerHTML = "

"; + + // Safari can't handle uppercase or unicode characters when + // in quirks mode. + if ( div.querySelectorAll && div.querySelectorAll(".TEST").length === 0 ) { + return; + } + + Sizzle = function( query, context, extra, seed ) { + context = context || document; + + // Only use querySelectorAll on non-XML documents + // (ID selectors don't work in non-HTML documents) + if ( !seed && !Sizzle.isXML(context) ) { + // See if we find a selector to speed up + var match = /^(\w+$)|^\.([\w\-]+$)|^#([\w\-]+$)/.exec( query ); + + if ( match && (context.nodeType === 1 || context.nodeType === 9) ) { + // Speed-up: Sizzle("TAG") + if ( match[1] ) { + return makeArray( context.getElementsByTagName( query ), extra ); + + // Speed-up: Sizzle(".CLASS") + } else if ( match[2] && Expr.find.CLASS && context.getElementsByClassName ) { + return makeArray( context.getElementsByClassName( match[2] ), extra ); + } + } + + if ( context.nodeType === 9 ) { + // Speed-up: Sizzle("body") + // The body element only exists once, optimize finding it + if ( query === "body" && context.body ) { + return makeArray( [ context.body ], extra ); + + // Speed-up: Sizzle("#ID") + } else if ( match && match[3] ) { + var elem = context.getElementById( match[3] ); + + // Check parentNode to catch when Blackberry 4.6 returns + // nodes that are no longer in the document #6963 + if ( elem && elem.parentNode ) { + // Handle the case where IE and Opera return items + // by name instead of ID + if ( elem.id === match[3] ) { + return makeArray( [ elem ], extra ); + } + + } else { + return makeArray( [], extra ); + } + } + + try { + return makeArray( context.querySelectorAll(query), extra ); + } catch(qsaError) {} + + // qSA works strangely on Element-rooted queries + // We can work around this by specifying an extra ID on the root + // and working up from there (Thanks to Andrew Dupont for the technique) + // IE 8 doesn't work on object elements + } else if ( context.nodeType === 1 && context.nodeName.toLowerCase() !== "object" ) { + var oldContext = context, + old = context.getAttribute( "id" ), + nid = old || id, + hasParent = context.parentNode, + relativeHierarchySelector = /^\s*[+~]/.test( query ); + + if ( !old ) { + context.setAttribute( "id", nid ); + } else { + nid = nid.replace( /'/g, "\\$&" ); + } + if ( relativeHierarchySelector && hasParent ) { + context = context.parentNode; + } + + try { + if ( !relativeHierarchySelector || hasParent ) { + return makeArray( context.querySelectorAll( "[id='" + nid + "'] " + query ), extra ); + } + + } catch(pseudoError) { + } finally { + if ( !old ) { + oldContext.removeAttribute( "id" ); + } + } + } + } + + return oldSizzle(query, context, extra, seed); + }; + + for ( var prop in oldSizzle ) { + Sizzle[ prop ] = oldSizzle[ prop ]; + } + + // release memory in IE + div = null; + })(); +} + +(function(){ + var html = document.documentElement, + matches = html.matchesSelector || html.mozMatchesSelector || html.webkitMatchesSelector || html.msMatchesSelector; + + if ( matches ) { + // Check to see if it's possible to do matchesSelector + // on a disconnected node (IE 9 fails this) + var disconnectedMatch = !matches.call( document.createElement( "div" ), "div" ), + pseudoWorks = false; + + try { + // This should fail with an exception + // Gecko does not error, returns false instead + matches.call( document.documentElement, "[test!='']:sizzle" ); + + } catch( pseudoError ) { + pseudoWorks = true; + } + + Sizzle.matchesSelector = function( node, expr ) { + // Make sure that attribute selectors are quoted + expr = expr.replace(/\=\s*([^'"\]]*)\s*\]/g, "='$1']"); + + if ( !Sizzle.isXML( node ) ) { + try { + if ( pseudoWorks || !Expr.match.PSEUDO.test( expr ) && !/!=/.test( expr ) ) { + var ret = matches.call( node, expr ); + + // IE 9's matchesSelector returns false on disconnected nodes + if ( ret || !disconnectedMatch || + // As well, disconnected nodes are said to be in a document + // fragment in IE 9, so check for that + node.document && node.document.nodeType !== 11 ) { + return ret; + } + } + } catch(e) {} + } + + return Sizzle(expr, null, null, [node]).length > 0; + }; + } +})(); + +(function(){ + var div = document.createElement("div"); + + div.innerHTML = "
"; + + // Opera can't find a second classname (in 9.6) + // Also, make sure that getElementsByClassName actually exists + if ( !div.getElementsByClassName || div.getElementsByClassName("e").length === 0 ) { + return; + } + + // Safari caches class attributes, doesn't catch changes (in 3.2) + div.lastChild.className = "e"; + + if ( div.getElementsByClassName("e").length === 1 ) { + return; + } + + Expr.order.splice(1, 0, "CLASS"); + Expr.find.CLASS = function( match, context, isXML ) { + if ( typeof context.getElementsByClassName !== "undefined" && !isXML ) { + return context.getElementsByClassName(match[1]); + } + }; + + // release memory in IE + div = null; +})(); + +function dirNodeCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) { + for ( var i = 0, l = checkSet.length; i < l; i++ ) { + var elem = checkSet[i]; + + if ( elem ) { + var match = false; + + elem = elem[dir]; + + while ( elem ) { + if ( elem[ expando ] === doneName ) { + match = checkSet[elem.sizset]; + break; + } + + if ( elem.nodeType === 1 && !isXML ){ + elem[ expando ] = doneName; + elem.sizset = i; + } + + if ( elem.nodeName.toLowerCase() === cur ) { + match = elem; + break; + } + + elem = elem[dir]; + } + + checkSet[i] = match; + } + } +} + +function dirCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) { + for ( var i = 0, l = checkSet.length; i < l; i++ ) { + var elem = checkSet[i]; + + if ( elem ) { + var match = false; + + elem = elem[dir]; + + while ( elem ) { + if ( elem[ expando ] === doneName ) { + match = checkSet[elem.sizset]; + break; + } + + if ( elem.nodeType === 1 ) { + if ( !isXML ) { + elem[ expando ] = doneName; + elem.sizset = i; + } + + if ( typeof cur !== "string" ) { + if ( elem === cur ) { + match = true; + break; + } + + } else if ( Sizzle.filter( cur, [elem] ).length > 0 ) { + match = elem; + break; + } + } + + elem = elem[dir]; + } + + checkSet[i] = match; + } + } +} + +if ( document.documentElement.contains ) { + Sizzle.contains = function( a, b ) { + return a !== b && (a.contains ? a.contains(b) : true); + }; + +} else if ( document.documentElement.compareDocumentPosition ) { + Sizzle.contains = function( a, b ) { + return !!(a.compareDocumentPosition(b) & 16); + }; + +} else { + Sizzle.contains = function() { + return false; + }; +} + +Sizzle.isXML = function( elem ) { + // documentElement is verified for cases where it doesn't yet exist + // (such as loading iframes in IE - #4833) + var documentElement = (elem ? elem.ownerDocument || elem : 0).documentElement; + + return documentElement ? documentElement.nodeName !== "HTML" : false; +}; + +var posProcess = function( selector, context, seed ) { + var match, + tmpSet = [], + later = "", + root = context.nodeType ? [context] : context; + + // Position selectors must be done after the filter + // And so must :not(positional) so we move all PSEUDOs to the end + while ( (match = Expr.match.PSEUDO.exec( selector )) ) { + later += match[0]; + selector = selector.replace( Expr.match.PSEUDO, "" ); + } + + selector = Expr.relative[selector] ? selector + "*" : selector; + + for ( var i = 0, l = root.length; i < l; i++ ) { + Sizzle( selector, root[i], tmpSet, seed ); + } + + return Sizzle.filter( later, tmpSet ); +}; + +// EXPOSE +// Override sizzle attribute retrieval +Sizzle.attr = jQuery.attr; +Sizzle.selectors.attrMap = {}; +jQuery.find = Sizzle; +jQuery.expr = Sizzle.selectors; +jQuery.expr[":"] = jQuery.expr.filters; +jQuery.unique = Sizzle.uniqueSort; +jQuery.text = Sizzle.getText; +jQuery.isXMLDoc = Sizzle.isXML; +jQuery.contains = Sizzle.contains; + + +})(); + + +var runtil = /Until$/, + rparentsprev = /^(?:parents|prevUntil|prevAll)/, + // Note: This RegExp should be improved, or likely pulled from Sizzle + rmultiselector = /,/, + isSimple = /^.[^:#\[\.,]*$/, + slice = Array.prototype.slice, + POS = jQuery.expr.match.globalPOS, + // methods guaranteed to produce a unique set when starting from a unique set + guaranteedUnique = { + children: true, + contents: true, + next: true, + prev: true + }; + +jQuery.fn.extend({ + find: function( selector ) { + var self = this, + i, l; + + if ( typeof selector !== "string" ) { + return jQuery( selector ).filter(function() { + for ( i = 0, l = self.length; i < l; i++ ) { + if ( jQuery.contains( self[ i ], this ) ) { + return true; + } + } + }); + } + + var ret = this.pushStack( "", "find", selector ), + length, n, r; + + for ( i = 0, l = this.length; i < l; i++ ) { + length = ret.length; + jQuery.find( selector, this[i], ret ); + + if ( i > 0 ) { + // Make sure that the results are unique + for ( n = length; n < ret.length; n++ ) { + for ( r = 0; r < length; r++ ) { + if ( ret[r] === ret[n] ) { + ret.splice(n--, 1); + break; + } + } + } + } + } + + return ret; + }, + + has: function( target ) { + var targets = jQuery( target ); + return this.filter(function() { + for ( var i = 0, l = targets.length; i < l; i++ ) { + if ( jQuery.contains( this, targets[i] ) ) { + return true; + } + } + }); + }, + + not: function( selector ) { + return this.pushStack( winnow(this, selector, false), "not", selector); + }, + + filter: function( selector ) { + return this.pushStack( winnow(this, selector, true), "filter", selector ); + }, + + is: function( selector ) { + return !!selector && ( + typeof selector === "string" ? + // If this is a positional selector, check membership in the returned set + // so $("p:first").is("p:last") won't return true for a doc with two "p". + POS.test( selector ) ? + jQuery( selector, this.context ).index( this[0] ) >= 0 : + jQuery.filter( selector, this ).length > 0 : + this.filter( selector ).length > 0 ); + }, + + closest: function( selectors, context ) { + var ret = [], i, l, cur = this[0]; + + // Array (deprecated as of jQuery 1.7) + if ( jQuery.isArray( selectors ) ) { + var level = 1; + + while ( cur && cur.ownerDocument && cur !== context ) { + for ( i = 0; i < selectors.length; i++ ) { + + if ( jQuery( cur ).is( selectors[ i ] ) ) { + ret.push({ selector: selectors[ i ], elem: cur, level: level }); + } + } + + cur = cur.parentNode; + level++; + } + + return ret; + } + + // String + var pos = POS.test( selectors ) || typeof selectors !== "string" ? + jQuery( selectors, context || this.context ) : + 0; + + for ( i = 0, l = this.length; i < l; i++ ) { + cur = this[i]; + + while ( cur ) { + if ( pos ? pos.index(cur) > -1 : jQuery.find.matchesSelector(cur, selectors) ) { + ret.push( cur ); + break; + + } else { + cur = cur.parentNode; + if ( !cur || !cur.ownerDocument || cur === context || cur.nodeType === 11 ) { + break; + } + } + } + } + + ret = ret.length > 1 ? jQuery.unique( ret ) : ret; + + return this.pushStack( ret, "closest", selectors ); + }, + + // Determine the position of an element within + // the matched set of elements + index: function( elem ) { + + // No argument, return index in parent + if ( !elem ) { + return ( this[0] && this[0].parentNode ) ? this.prevAll().length : -1; + } + + // index in selector + if ( typeof elem === "string" ) { + return jQuery.inArray( this[0], jQuery( elem ) ); + } + + // Locate the position of the desired element + return jQuery.inArray( + // If it receives a jQuery object, the first element is used + elem.jquery ? elem[0] : elem, this ); + }, + + add: function( selector, context ) { + var set = typeof selector === "string" ? + jQuery( selector, context ) : + jQuery.makeArray( selector && selector.nodeType ? [ selector ] : selector ), + all = jQuery.merge( this.get(), set ); + + return this.pushStack( isDisconnected( set[0] ) || isDisconnected( all[0] ) ? + all : + jQuery.unique( all ) ); + }, + + andSelf: function() { + return this.add( this.prevObject ); + } +}); + +// A painfully simple check to see if an element is disconnected +// from a document (should be improved, where feasible). +function isDisconnected( node ) { + return !node || !node.parentNode || node.parentNode.nodeType === 11; +} + +jQuery.each({ + parent: function( elem ) { + var parent = elem.parentNode; + return parent && parent.nodeType !== 11 ? parent : null; + }, + parents: function( elem ) { + return jQuery.dir( elem, "parentNode" ); + }, + parentsUntil: function( elem, i, until ) { + return jQuery.dir( elem, "parentNode", until ); + }, + next: function( elem ) { + return jQuery.nth( elem, 2, "nextSibling" ); + }, + prev: function( elem ) { + return jQuery.nth( elem, 2, "previousSibling" ); + }, + nextAll: function( elem ) { + return jQuery.dir( elem, "nextSibling" ); + }, + prevAll: function( elem ) { + return jQuery.dir( elem, "previousSibling" ); + }, + nextUntil: function( elem, i, until ) { + return jQuery.dir( elem, "nextSibling", until ); + }, + prevUntil: function( elem, i, until ) { + return jQuery.dir( elem, "previousSibling", until ); + }, + siblings: function( elem ) { + return jQuery.sibling( ( elem.parentNode || {} ).firstChild, elem ); + }, + children: function( elem ) { + return jQuery.sibling( elem.firstChild ); + }, + contents: function( elem ) { + return jQuery.nodeName( elem, "iframe" ) ? + elem.contentDocument || elem.contentWindow.document : + jQuery.makeArray( elem.childNodes ); + } +}, function( name, fn ) { + jQuery.fn[ name ] = function( until, selector ) { + var ret = jQuery.map( this, fn, until ); + + if ( !runtil.test( name ) ) { + selector = until; + } + + if ( selector && typeof selector === "string" ) { + ret = jQuery.filter( selector, ret ); + } + + ret = this.length > 1 && !guaranteedUnique[ name ] ? jQuery.unique( ret ) : ret; + + if ( (this.length > 1 || rmultiselector.test( selector )) && rparentsprev.test( name ) ) { + ret = ret.reverse(); + } + + return this.pushStack( ret, name, slice.call( arguments ).join(",") ); + }; +}); + +jQuery.extend({ + filter: function( expr, elems, not ) { + if ( not ) { + expr = ":not(" + expr + ")"; + } + + return elems.length === 1 ? + jQuery.find.matchesSelector(elems[0], expr) ? [ elems[0] ] : [] : + jQuery.find.matches(expr, elems); + }, + + dir: function( elem, dir, until ) { + var matched = [], + cur = elem[ dir ]; + + while ( cur && cur.nodeType !== 9 && (until === undefined || cur.nodeType !== 1 || !jQuery( cur ).is( until )) ) { + if ( cur.nodeType === 1 ) { + matched.push( cur ); + } + cur = cur[dir]; + } + return matched; + }, + + nth: function( cur, result, dir, elem ) { + result = result || 1; + var num = 0; + + for ( ; cur; cur = cur[dir] ) { + if ( cur.nodeType === 1 && ++num === result ) { + break; + } + } + + return cur; + }, + + sibling: function( n, elem ) { + var r = []; + + for ( ; n; n = n.nextSibling ) { + if ( n.nodeType === 1 && n !== elem ) { + r.push( n ); + } + } + + return r; + } +}); + +// Implement the identical functionality for filter and not +function winnow( elements, qualifier, keep ) { + + // Can't pass null or undefined to indexOf in Firefox 4 + // Set to 0 to skip string check + qualifier = qualifier || 0; + + if ( jQuery.isFunction( qualifier ) ) { + return jQuery.grep(elements, function( elem, i ) { + var retVal = !!qualifier.call( elem, i, elem ); + return retVal === keep; + }); + + } else if ( qualifier.nodeType ) { + return jQuery.grep(elements, function( elem, i ) { + return ( elem === qualifier ) === keep; + }); + + } else if ( typeof qualifier === "string" ) { + var filtered = jQuery.grep(elements, function( elem ) { + return elem.nodeType === 1; + }); + + if ( isSimple.test( qualifier ) ) { + return jQuery.filter(qualifier, filtered, !keep); + } else { + qualifier = jQuery.filter( qualifier, filtered ); + } + } + + return jQuery.grep(elements, function( elem, i ) { + return ( jQuery.inArray( elem, qualifier ) >= 0 ) === keep; + }); +} + + + + +function createSafeFragment( document ) { + var list = nodeNames.split( "|" ), + safeFrag = document.createDocumentFragment(); + + if ( safeFrag.createElement ) { + while ( list.length ) { + safeFrag.createElement( + list.pop() + ); + } + } + return safeFrag; +} + +var nodeNames = "abbr|article|aside|audio|bdi|canvas|data|datalist|details|figcaption|figure|footer|" + + "header|hgroup|mark|meter|nav|output|progress|section|summary|time|video", + rinlinejQuery = / jQuery\d+="(?:\d+|null)"/g, + rleadingWhitespace = /^\s+/, + rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/ig, + rtagName = /<([\w:]+)/, + rtbody = /]", "i"), + // checked="checked" or checked + rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i, + rscriptType = /\/(java|ecma)script/i, + rcleanScript = /^\s*", "" ], + legend: [ 1, "
", "
" ], + thead: [ 1, "", "
" ], + tr: [ 2, "", "
" ], + td: [ 3, "", "
" ], + col: [ 2, "", "
" ], + area: [ 1, "", "" ], + _default: [ 0, "", "" ] + }, + safeFragment = createSafeFragment( document ); + +wrapMap.optgroup = wrapMap.option; +wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead; +wrapMap.th = wrapMap.td; + +// IE can't serialize and ' ); + + iframe_doc.close(); + + // Update the Iframe's hash, for great justice. + iframe.location.hash = hash; + } + }; + + })(); + // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + // ^^^^^^^^^^^^^^^^^^^ REMOVE IF NOT SUPPORTING IE6/7/8 ^^^^^^^^^^^^^^^^^^^ + // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + return self; + })(); + +})(jQuery,this); + + +(function( $, window, undefined ) { + +var createHandler = function( sequential ) { + + // Default to sequential + if ( sequential === undefined ) { + sequential = true; + } + + return function( name, reverse, $to, $from ) { + + var deferred = new $.Deferred(), + reverseClass = reverse ? " reverse" : "", + active = $.mobile.urlHistory.getActive(), + toScroll = active.lastScroll || $.mobile.defaultHomeScroll, + screenHeight = $.mobile.getScreenHeight(), + maxTransitionOverride = $.mobile.maxTransitionWidth !== false && $( window ).width() > $.mobile.maxTransitionWidth, + none = !$.support.cssTransitions || maxTransitionOverride || !name || name === "none" || Math.max( $( window ).scrollTop(), toScroll ) > $.mobile.getMaxScrollForTransition(), + toPreClass = " ui-page-pre-in", + toggleViewportClass = function() { + $.mobile.pageContainer.toggleClass( "ui-mobile-viewport-transitioning viewport-" + name ); + }, + scrollPage = function() { + // By using scrollTo instead of silentScroll, we can keep things better in order + // Just to be precautios, disable scrollstart listening like silentScroll would + $.event.special.scrollstart.enabled = false; + + window.scrollTo( 0, toScroll ); + + // reenable scrollstart listening like silentScroll would + setTimeout( function() { + $.event.special.scrollstart.enabled = true; + }, 150 ); + }, + cleanFrom = function() { + $from + .removeClass( $.mobile.activePageClass + " out in reverse " + name ) + .height( "" ); + }, + startOut = function() { + // if it's not sequential, call the doneOut transition to start the TO page animating in simultaneously + if ( !sequential ) { + doneOut(); + } + else { + $from.animationComplete( doneOut ); + } + + // Set the from page's height and start it transitioning out + // Note: setting an explicit height helps eliminate tiling in the transitions + $from + .height( screenHeight + $( window ).scrollTop() ) + .addClass( name + " out" + reverseClass ); + }, + + doneOut = function() { + + if ( $from && sequential ) { + cleanFrom(); + } + + startIn(); + }, + + startIn = function() { + + // Prevent flickering in phonegap container: see comments at #4024 regarding iOS + $to.css( "z-index", -10 ); + + $to.addClass( $.mobile.activePageClass + toPreClass ); + + // Send focus to page as it is now display: block + $.mobile.focusPage( $to ); + + // Set to page height + $to.height( screenHeight + toScroll ); + + scrollPage(); + + // Restores visibility of the new page: added together with $to.css( "z-index", -10 ); + $to.css( "z-index", "" ); + + if ( !none ) { + $to.animationComplete( doneIn ); + } + + $to + .removeClass( toPreClass ) + .addClass( name + " in" + reverseClass ); + + if ( none ) { + doneIn(); + } + + }, + + doneIn = function() { + + if ( !sequential ) { + + if ( $from ) { + cleanFrom(); + } + } + + $to + .removeClass( "out in reverse " + name ) + .height( "" ); + + toggleViewportClass(); + + // In some browsers (iOS5), 3D transitions block the ability to scroll to the desired location during transition + // This ensures we jump to that spot after the fact, if we aren't there already. + if ( $( window ).scrollTop() !== toScroll ) { + scrollPage(); + } + + deferred.resolve( name, reverse, $to, $from, true ); + }; + + toggleViewportClass(); + + if ( $from && !none ) { + startOut(); + } + else { + doneOut(); + } + + return deferred.promise(); + }; +}; + +// generate the handlers from the above +var sequentialHandler = createHandler(), + simultaneousHandler = createHandler( false ), + defaultGetMaxScrollForTransition = function() { + return $.mobile.getScreenHeight() * 3; + }; + +// Make our transition handler the public default. +$.mobile.defaultTransitionHandler = sequentialHandler; + +//transition handler dictionary for 3rd party transitions +$.mobile.transitionHandlers = { + "default": $.mobile.defaultTransitionHandler, + "sequential": sequentialHandler, + "simultaneous": simultaneousHandler +}; + +$.mobile.transitionFallbacks = {}; + +// If transition is defined, check if css 3D transforms are supported, and if not, if a fallback is specified +$.mobile._maybeDegradeTransition = function( transition ) { + if ( transition && !$.support.cssTransform3d && $.mobile.transitionFallbacks[ transition ] ) { + transition = $.mobile.transitionFallbacks[ transition ]; + } + + return transition; +}; + +// Set the getMaxScrollForTransition to default if no implementation was set by user +$.mobile.getMaxScrollForTransition = $.mobile.getMaxScrollForTransition || defaultGetMaxScrollForTransition; +})( jQuery, this ); + +(function( $, undefined ) { + + //define vars for interal use + var $window = $( window ), + $html = $( 'html' ), + $head = $( 'head' ), + + //url path helpers for use in relative url management + path = { + + // This scary looking regular expression parses an absolute URL or its relative + // variants (protocol, site, document, query, and hash), into the various + // components (protocol, host, path, query, fragment, etc that make up the + // URL as well as some other commonly used sub-parts. When used with RegExp.exec() + // or String.match, it parses the URL into a results array that looks like this: + // + // [0]: http://jblas:password@mycompany.com:8080/mail/inbox?msg=1234&type=unread#msg-content + // [1]: http://jblas:password@mycompany.com:8080/mail/inbox?msg=1234&type=unread + // [2]: http://jblas:password@mycompany.com:8080/mail/inbox + // [3]: http://jblas:password@mycompany.com:8080 + // [4]: http: + // [5]: // + // [6]: jblas:password@mycompany.com:8080 + // [7]: jblas:password + // [8]: jblas + // [9]: password + // [10]: mycompany.com:8080 + // [11]: mycompany.com + // [12]: 8080 + // [13]: /mail/inbox + // [14]: /mail/ + // [15]: inbox + // [16]: ?msg=1234&type=unread + // [17]: #msg-content + // + urlParseRE: /^(((([^:\/#\?]+:)?(?:(\/\/)((?:(([^:@\/#\?]+)(?:\:([^:@\/#\?]+))?)@)?(([^:\/#\?\]\[]+|\[[^\/\]@#?]+\])(?:\:([0-9]+))?))?)?)?((\/?(?:[^\/\?#]+\/+)*)([^\?#]*)))?(\?[^#]+)?)(#.*)?/, + + // Abstraction to address xss (Issue #4787) by removing the authority in + // browsers that auto decode it. All references to location.href should be + // replaced with a call to this method so that it can be dealt with properly here + getLocation: function( url ) { + var uri = url ? this.parseUrl( url ) : location, + hash = this.parseUrl( url || location.href ).hash; + + // mimic the browser with an empty string when the hash is empty + hash = hash === "#" ? "" : hash; + + // Make sure to parse the url or the location object for the hash because using location.hash + // is autodecoded in firefox, the rest of the url should be from the object (location unless + // we're testing) to avoid the inclusion of the authority + return uri.protocol + "//" + uri.host + uri.pathname + uri.search + hash; + }, + + parseLocation: function() { + return this.parseUrl( this.getLocation() ); + }, + + //Parse a URL into a structure that allows easy access to + //all of the URL components by name. + parseUrl: function( url ) { + // If we're passed an object, we'll assume that it is + // a parsed url object and just return it back to the caller. + if ( $.type( url ) === "object" ) { + return url; + } + + var matches = path.urlParseRE.exec( url || "" ) || []; + + // Create an object that allows the caller to access the sub-matches + // by name. Note that IE returns an empty string instead of undefined, + // like all other browsers do, so we normalize everything so its consistent + // no matter what browser we're running on. + return { + href: matches[ 0 ] || "", + hrefNoHash: matches[ 1 ] || "", + hrefNoSearch: matches[ 2 ] || "", + domain: matches[ 3 ] || "", + protocol: matches[ 4 ] || "", + doubleSlash: matches[ 5 ] || "", + authority: matches[ 6 ] || "", + username: matches[ 8 ] || "", + password: matches[ 9 ] || "", + host: matches[ 10 ] || "", + hostname: matches[ 11 ] || "", + port: matches[ 12 ] || "", + pathname: matches[ 13 ] || "", + directory: matches[ 14 ] || "", + filename: matches[ 15 ] || "", + search: matches[ 16 ] || "", + hash: matches[ 17 ] || "" + }; + }, + + //Turn relPath into an asbolute path. absPath is + //an optional absolute path which describes what + //relPath is relative to. + makePathAbsolute: function( relPath, absPath ) { + if ( relPath && relPath.charAt( 0 ) === "/" ) { + return relPath; + } + + relPath = relPath || ""; + absPath = absPath ? absPath.replace( /^\/|(\/[^\/]*|[^\/]+)$/g, "" ) : ""; + + var absStack = absPath ? absPath.split( "/" ) : [], + relStack = relPath.split( "/" ); + for ( var i = 0; i < relStack.length; i++ ) { + var d = relStack[ i ]; + switch ( d ) { + case ".": + break; + case "..": + if ( absStack.length ) { + absStack.pop(); + } + break; + default: + absStack.push( d ); + break; + } + } + return "/" + absStack.join( "/" ); + }, + + //Returns true if both urls have the same domain. + isSameDomain: function( absUrl1, absUrl2 ) { + return path.parseUrl( absUrl1 ).domain === path.parseUrl( absUrl2 ).domain; + }, + + //Returns true for any relative variant. + isRelativeUrl: function( url ) { + // All relative Url variants have one thing in common, no protocol. + return path.parseUrl( url ).protocol === ""; + }, + + //Returns true for an absolute url. + isAbsoluteUrl: function( url ) { + return path.parseUrl( url ).protocol !== ""; + }, + + //Turn the specified realtive URL into an absolute one. This function + //can handle all relative variants (protocol, site, document, query, fragment). + makeUrlAbsolute: function( relUrl, absUrl ) { + if ( !path.isRelativeUrl( relUrl ) ) { + return relUrl; + } + + if ( absUrl === undefined ) { + absUrl = documentBase; + } + + var relObj = path.parseUrl( relUrl ), + absObj = path.parseUrl( absUrl ), + protocol = relObj.protocol || absObj.protocol, + doubleSlash = relObj.protocol ? relObj.doubleSlash : ( relObj.doubleSlash || absObj.doubleSlash ), + authority = relObj.authority || absObj.authority, + hasPath = relObj.pathname !== "", + pathname = path.makePathAbsolute( relObj.pathname || absObj.filename, absObj.pathname ), + search = relObj.search || ( !hasPath && absObj.search ) || "", + hash = relObj.hash; + + return protocol + doubleSlash + authority + pathname + search + hash; + }, + + //Add search (aka query) params to the specified url. + addSearchParams: function( url, params ) { + var u = path.parseUrl( url ), + p = ( typeof params === "object" ) ? $.param( params ) : params, + s = u.search || "?"; + return u.hrefNoSearch + s + ( s.charAt( s.length - 1 ) !== "?" ? "&" : "" ) + p + ( u.hash || "" ); + }, + + convertUrlToDataUrl: function( absUrl ) { + var u = path.parseUrl( absUrl ); + if ( path.isEmbeddedPage( u ) ) { + // For embedded pages, remove the dialog hash key as in getFilePath(), + // otherwise the Data Url won't match the id of the embedded Page. + return u.hash.split( dialogHashKey )[0].replace( /^#/, "" ); + } else if ( path.isSameDomain( u, documentBase ) ) { + return u.hrefNoHash.replace( documentBase.domain, "" ).split( dialogHashKey )[0]; + } + + return window.decodeURIComponent(absUrl); + }, + + //get path from current hash, or from a file path + get: function( newPath ) { + if ( newPath === undefined ) { + newPath = path.parseLocation().hash; + } + return path.stripHash( newPath ).replace( /[^\/]*\.[^\/*]+$/, '' ); + }, + + //return the substring of a filepath before the sub-page key, for making a server request + getFilePath: function( path ) { + var splitkey = '&' + $.mobile.subPageUrlKey; + return path && path.split( splitkey )[0].split( dialogHashKey )[0]; + }, + + //set location hash to path + set: function( path ) { + location.hash = path; + }, + + //test if a given url (string) is a path + //NOTE might be exceptionally naive + isPath: function( url ) { + return ( /\// ).test( url ); + }, + + //return a url path with the window's location protocol/hostname/pathname removed + clean: function( url ) { + return url.replace( documentBase.domain, "" ); + }, + + //just return the url without an initial # + stripHash: function( url ) { + return url.replace( /^#/, "" ); + }, + + //remove the preceding hash, any query params, and dialog notations + cleanHash: function( hash ) { + return path.stripHash( hash.replace( /\?.*$/, "" ).replace( dialogHashKey, "" ) ); + }, + + isHashValid: function( hash ) { + return ( /^#[^#]+$/ ).test( hash ); + }, + + //check whether a url is referencing the same domain, or an external domain or different protocol + //could be mailto, etc + isExternal: function( url ) { + var u = path.parseUrl( url ); + return u.protocol && u.domain !== documentUrl.domain ? true : false; + }, + + hasProtocol: function( url ) { + return ( /^(:?\w+:)/ ).test( url ); + }, + + //check if the specified url refers to the first page in the main application document. + isFirstPageUrl: function( url ) { + // We only deal with absolute paths. + var u = path.parseUrl( path.makeUrlAbsolute( url, documentBase ) ), + + // Does the url have the same path as the document? + samePath = u.hrefNoHash === documentUrl.hrefNoHash || ( documentBaseDiffers && u.hrefNoHash === documentBase.hrefNoHash ), + + // Get the first page element. + fp = $.mobile.firstPage, + + // Get the id of the first page element if it has one. + fpId = fp && fp[0] ? fp[0].id : undefined; + + // The url refers to the first page if the path matches the document and + // it either has no hash value, or the hash is exactly equal to the id of the + // first page element. + return samePath && ( !u.hash || u.hash === "#" || ( fpId && u.hash.replace( /^#/, "" ) === fpId ) ); + }, + + isEmbeddedPage: function( url ) { + var u = path.parseUrl( url ); + + //if the path is absolute, then we need to compare the url against + //both the documentUrl and the documentBase. The main reason for this + //is that links embedded within external documents will refer to the + //application document, whereas links embedded within the application + //document will be resolved against the document base. + if ( u.protocol !== "" ) { + return ( u.hash && ( u.hrefNoHash === documentUrl.hrefNoHash || ( documentBaseDiffers && u.hrefNoHash === documentBase.hrefNoHash ) ) ); + } + return ( /^#/ ).test( u.href ); + }, + + + // Some embedded browsers, like the web view in Phone Gap, allow cross-domain XHR + // requests if the document doing the request was loaded via the file:// protocol. + // This is usually to allow the application to "phone home" and fetch app specific + // data. We normally let the browser handle external/cross-domain urls, but if the + // allowCrossDomainPages option is true, we will allow cross-domain http/https + // requests to go through our page loading logic. + isPermittedCrossDomainRequest: function( docUrl, reqUrl ) { + return $.mobile.allowCrossDomainPages && + docUrl.protocol === "file:" && + reqUrl.search( /^https?:/ ) !== -1; + } + }, + + //will be defined when a link is clicked and given an active class + $activeClickedLink = null, + + //urlHistory is purely here to make guesses at whether the back or forward button was clicked + //and provide an appropriate transition + urlHistory = { + // Array of pages that are visited during a single page load. + // Each has a url and optional transition, title, and pageUrl (which represents the file path, in cases where URL is obscured, such as dialogs) + stack: [], + + //maintain an index number for the active page in the stack + activeIndex: 0, + + //get active + getActive: function() { + return urlHistory.stack[ urlHistory.activeIndex ]; + }, + + getPrev: function() { + return urlHistory.stack[ urlHistory.activeIndex - 1 ]; + }, + + getNext: function() { + return urlHistory.stack[ urlHistory.activeIndex + 1 ]; + }, + + // addNew is used whenever a new page is added + addNew: function( url, transition, title, pageUrl, role ) { + //if there's forward history, wipe it + if ( urlHistory.getNext() ) { + urlHistory.clearForward(); + } + + urlHistory.stack.push( {url : url, transition: transition, title: title, pageUrl: pageUrl, role: role } ); + + urlHistory.activeIndex = urlHistory.stack.length - 1; + }, + + //wipe urls ahead of active index + clearForward: function() { + urlHistory.stack = urlHistory.stack.slice( 0, urlHistory.activeIndex + 1 ); + }, + + directHashChange: function( opts ) { + var back , forward, newActiveIndex, prev = this.getActive(); + + // check if url is in history and if it's ahead or behind current page + $.each( urlHistory.stack, function( i, historyEntry ) { + + //if the url is in the stack, it's a forward or a back + if ( decodeURIComponent( opts.currentUrl ) === decodeURIComponent( historyEntry.url ) ) { + //define back and forward by whether url is older or newer than current page + back = i < urlHistory.activeIndex; + forward = !back; + newActiveIndex = i; + } + }); + + // save new page index, null check to prevent falsey 0 result + this.activeIndex = newActiveIndex !== undefined ? newActiveIndex : this.activeIndex; + + if ( back ) { + ( opts.either || opts.isBack )( true ); + } else if ( forward ) { + ( opts.either || opts.isForward )( false ); + } + }, + + //disable hashchange event listener internally to ignore one change + //toggled internally when location.hash is updated to match the url of a successful page load + ignoreNextHashChange: false + }, + + //define first selector to receive focus when a page is shown + focusable = "[tabindex],a,button:visible,select:visible,input", + + //queue to hold simultanious page transitions + pageTransitionQueue = [], + + //indicates whether or not page is in process of transitioning + isPageTransitioning = false, + + //nonsense hash change key for dialogs, so they create a history entry + dialogHashKey = "&ui-state=dialog", + + //existing base tag? + $base = $head.children( "base" ), + + //tuck away the original document URL minus any fragment. + documentUrl = path.parseLocation(), + + //if the document has an embedded base tag, documentBase is set to its + //initial value. If a base tag does not exist, then we default to the documentUrl. + documentBase = $base.length ? path.parseUrl( path.makeUrlAbsolute( $base.attr( "href" ), documentUrl.href ) ) : documentUrl, + + //cache the comparison once. + documentBaseDiffers = ( documentUrl.hrefNoHash !== documentBase.hrefNoHash ), + + getScreenHeight = $.mobile.getScreenHeight; + + //base element management, defined depending on dynamic base tag support + var base = $.support.dynamicBaseTag ? { + + //define base element, for use in routing asset urls that are referenced in Ajax-requested markup + element: ( $base.length ? $base : $( "", { href: documentBase.hrefNoHash } ).prependTo( $head ) ), + + //set the generated BASE element's href attribute to a new page's base path + set: function( href ) { + base.element.attr( "href", path.makeUrlAbsolute( href, documentBase ) ); + }, + + //set the generated BASE element's href attribute to a new page's base path + reset: function() { + base.element.attr( "href", documentBase.hrefNoHash ); + } + + } : undefined; + + /* internal utility functions */ + + // NOTE Issue #4950 Android phonegap doesn't navigate back properly + // when a full page refresh has taken place. It appears that hashchange + // and replacestate history alterations work fine but we need to support + // both forms of history traversal in our code that uses backward history + // movement + $.mobile.back = function() { + var nav = window.navigator; + + // if the setting is on and the navigator object is + // available use the phonegap navigation capability + if( this.phonegapNavigationEnabled && + nav && + nav.app && + nav.app.backHistory ){ + nav.app.backHistory(); + } else { + window.history.back(); + } + }; + + //direct focus to the page title, or otherwise first focusable element + $.mobile.focusPage = function ( page ) { + var autofocus = page.find( "[autofocus]" ), + pageTitle = page.find( ".ui-title:eq(0)" ); + + if ( autofocus.length ) { + autofocus.focus(); + return; + } + + if ( pageTitle.length ) { + pageTitle.focus(); + } else{ + page.focus(); + } + }; + + //remove active classes after page transition or error + function removeActiveLinkClass( forceRemoval ) { + if ( !!$activeClickedLink && ( !$activeClickedLink.closest( "." + $.mobile.activePageClass ).length || forceRemoval ) ) { + $activeClickedLink.removeClass( $.mobile.activeBtnClass ); + } + $activeClickedLink = null; + } + + function releasePageTransitionLock() { + isPageTransitioning = false; + if ( pageTransitionQueue.length > 0 ) { + $.mobile.changePage.apply( null, pageTransitionQueue.pop() ); + } + } + + // Save the last scroll distance per page, before it is hidden + var setLastScrollEnabled = true, + setLastScroll, delayedSetLastScroll; + + setLastScroll = function() { + // this barrier prevents setting the scroll value based on the browser + // scrolling the window based on a hashchange + if ( !setLastScrollEnabled ) { + return; + } + + var active = $.mobile.urlHistory.getActive(); + + if ( active ) { + var lastScroll = $window.scrollTop(); + + // Set active page's lastScroll prop. + // If the location we're scrolling to is less than minScrollBack, let it go. + active.lastScroll = lastScroll < $.mobile.minScrollBack ? $.mobile.defaultHomeScroll : lastScroll; + } + }; + + // bind to scrollstop to gather scroll position. The delay allows for the hashchange + // event to fire and disable scroll recording in the case where the browser scrolls + // to the hash targets location (sometimes the top of the page). once pagechange fires + // getLastScroll is again permitted to operate + delayedSetLastScroll = function() { + setTimeout( setLastScroll, 100 ); + }; + + // disable an scroll setting when a hashchange has been fired, this only works + // because the recording of the scroll position is delayed for 100ms after + // the browser might have changed the position because of the hashchange + $window.bind( $.support.pushState ? "popstate" : "hashchange", function() { + setLastScrollEnabled = false; + }); + + // handle initial hashchange from chrome :( + $window.one( $.support.pushState ? "popstate" : "hashchange", function() { + setLastScrollEnabled = true; + }); + + // wait until the mobile page container has been determined to bind to pagechange + $window.one( "pagecontainercreate", function() { + // once the page has changed, re-enable the scroll recording + $.mobile.pageContainer.bind( "pagechange", function() { + + setLastScrollEnabled = true; + + // remove any binding that previously existed on the get scroll + // which may or may not be different than the scroll element determined for + // this page previously + $window.unbind( "scrollstop", delayedSetLastScroll ); + + // determine and bind to the current scoll element which may be the window + // or in the case of touch overflow the element with touch overflow + $window.bind( "scrollstop", delayedSetLastScroll ); + }); + }); + + // bind to scrollstop for the first page as "pagechange" won't be fired in that case + $window.bind( "scrollstop", delayedSetLastScroll ); + + // No-op implementation of transition degradation + $.mobile._maybeDegradeTransition = $.mobile._maybeDegradeTransition || function( transition ) { + return transition; + }; + + //function for transitioning between two existing pages + function transitionPages( toPage, fromPage, transition, reverse ) { + + if ( fromPage ) { + //trigger before show/hide events + fromPage.data( "page" )._trigger( "beforehide", null, { nextPage: toPage } ); + } + + toPage.data( "page" )._trigger( "beforeshow", null, { prevPage: fromPage || $( "" ) } ); + + //clear page loader + $.mobile.hidePageLoadingMsg(); + + transition = $.mobile._maybeDegradeTransition( transition ); + + //find the transition handler for the specified transition. If there + //isn't one in our transitionHandlers dictionary, use the default one. + //call the handler immediately to kick-off the transition. + var th = $.mobile.transitionHandlers[ transition || "default" ] || $.mobile.defaultTransitionHandler, + promise = th( transition, reverse, toPage, fromPage ); + + promise.done(function() { + + //trigger show/hide events + if ( fromPage ) { + fromPage.data( "page" )._trigger( "hide", null, { nextPage: toPage } ); + } + + //trigger pageshow, define prevPage as either fromPage or empty jQuery obj + toPage.data( "page" )._trigger( "show", null, { prevPage: fromPage || $( "" ) } ); + }); + + return promise; + } + + //simply set the active page's minimum height to screen height, depending on orientation + function resetActivePageHeight() { + var aPage = $( "." + $.mobile.activePageClass ), + aPagePadT = parseFloat( aPage.css( "padding-top" ) ), + aPagePadB = parseFloat( aPage.css( "padding-bottom" ) ), + aPageBorderT = parseFloat( aPage.css( "border-top-width" ) ), + aPageBorderB = parseFloat( aPage.css( "border-bottom-width" ) ); + + aPage.css( "min-height", getScreenHeight() - aPagePadT - aPagePadB - aPageBorderT - aPageBorderB ); + } + + //shared page enhancements + function enhancePage( $page, role ) { + // If a role was specified, make sure the data-role attribute + // on the page element is in sync. + if ( role ) { + $page.attr( "data-" + $.mobile.ns + "role", role ); + } + + //run page plugin + $page.page(); + } + + /* exposed $.mobile methods */ + + //animation complete callback + $.fn.animationComplete = function( callback ) { + if ( $.support.cssTransitions ) { + return $( this ).one( 'webkitAnimationEnd animationend', callback ); + } + else{ + // defer execution for consistency between webkit/non webkit + setTimeout( callback, 0 ); + return $( this ); + } + }; + + //expose path object on $.mobile + $.mobile.path = path; + + //expose base object on $.mobile + $.mobile.base = base; + + //history stack + $.mobile.urlHistory = urlHistory; + + $.mobile.dialogHashKey = dialogHashKey; + + + + //enable cross-domain page support + $.mobile.allowCrossDomainPages = false; + + //return the original document url + $.mobile.getDocumentUrl = function( asParsedObject ) { + return asParsedObject ? $.extend( {}, documentUrl ) : documentUrl.href; + }; + + //return the original document base url + $.mobile.getDocumentBase = function( asParsedObject ) { + return asParsedObject ? $.extend( {}, documentBase ) : documentBase.href; + }; + + $.mobile._bindPageRemove = function() { + var page = $( this ); + + // when dom caching is not enabled or the page is embedded bind to remove the page on hide + if ( !page.data( "page" ).options.domCache && + page.is( ":jqmData(external-page='true')" ) ) { + + page.bind( 'pagehide.remove', function() { + var $this = $( this ), + prEvent = new $.Event( "pageremove" ); + + $this.trigger( prEvent ); + + if ( !prEvent.isDefaultPrevented() ) { + $this.removeWithDependents(); + } + }); + } + }; + + // Load a page into the DOM. + $.mobile.loadPage = function( url, options ) { + // This function uses deferred notifications to let callers + // know when the page is done loading, or if an error has occurred. + var deferred = $.Deferred(), + + // The default loadPage options with overrides specified by + // the caller. + settings = $.extend( {}, $.mobile.loadPage.defaults, options ), + + // The DOM element for the page after it has been loaded. + page = null, + + // If the reloadPage option is true, and the page is already + // in the DOM, dupCachedPage will be set to the page element + // so that it can be removed after the new version of the + // page is loaded off the network. + dupCachedPage = null, + + // determine the current base url + findBaseWithDefault = function() { + var closestBase = ( $.mobile.activePage && getClosestBaseUrl( $.mobile.activePage ) ); + return closestBase || documentBase.hrefNoHash; + }, + + // The absolute version of the URL passed into the function. This + // version of the URL may contain dialog/subpage params in it. + absUrl = path.makeUrlAbsolute( url, findBaseWithDefault() ); + + + // If the caller provided data, and we're using "get" request, + // append the data to the URL. + if ( settings.data && settings.type === "get" ) { + absUrl = path.addSearchParams( absUrl, settings.data ); + settings.data = undefined; + } + + // If the caller is using a "post" request, reloadPage must be true + if ( settings.data && settings.type === "post" ) { + settings.reloadPage = true; + } + + // The absolute version of the URL minus any dialog/subpage params. + // In otherwords the real URL of the page to be loaded. + var fileUrl = path.getFilePath( absUrl ), + + // The version of the Url actually stored in the data-url attribute of + // the page. For embedded pages, it is just the id of the page. For pages + // within the same domain as the document base, it is the site relative + // path. For cross-domain pages (Phone Gap only) the entire absolute Url + // used to load the page. + dataUrl = path.convertUrlToDataUrl( absUrl ); + + // Make sure we have a pageContainer to work with. + settings.pageContainer = settings.pageContainer || $.mobile.pageContainer; + + // Check to see if the page already exists in the DOM. + // NOTE do _not_ use the :jqmData psuedo selector because parenthesis + // are a valid url char and it breaks on the first occurence + page = settings.pageContainer.children( "[data-" + $.mobile.ns +"url='" + dataUrl + "']" ); + + // If we failed to find the page, check to see if the url is a + // reference to an embedded page. If so, it may have been dynamically + // injected by a developer, in which case it would be lacking a data-url + // attribute and in need of enhancement. + if ( page.length === 0 && dataUrl && !path.isPath( dataUrl ) ) { + page = settings.pageContainer.children( "#" + dataUrl ) + .attr( "data-" + $.mobile.ns + "url", dataUrl ) + .jqmData( "url", dataUrl ); + } + + + // If we failed to find a page in the DOM, check the URL to see if it + // refers to the first page in the application. If it isn't a reference + // to the first page and refers to non-existent embedded page, error out. + if ( page.length === 0 ) { + if ( $.mobile.firstPage && path.isFirstPageUrl( fileUrl ) ) { + // Check to make sure our cached-first-page is actually + // in the DOM. Some user deployed apps are pruning the first + // page from the DOM for various reasons, we check for this + // case here because we don't want a first-page with an id + // falling through to the non-existent embedded page error + // case. If the first-page is not in the DOM, then we let + // things fall through to the ajax loading code below so + // that it gets reloaded. + if ( $.mobile.firstPage.parent().length ) { + page = $( $.mobile.firstPage ); + } + } else if ( path.isEmbeddedPage( fileUrl ) ) { + deferred.reject( absUrl, options ); + return deferred.promise(); + } + } + + // If the page we are interested in is already in the DOM, + // and the caller did not indicate that we should force a + // reload of the file, we are done. Otherwise, track the + // existing page as a duplicated. + if ( page.length ) { + if ( !settings.reloadPage ) { + enhancePage( page, settings.role ); + deferred.resolve( absUrl, options, page ); + //if we are reloading the page make sure we update the base if its not a prefetch + if( base && !options.prefetch ){ + base.set(url); + } + return deferred.promise(); + } + dupCachedPage = page; + } + var mpc = settings.pageContainer, + pblEvent = new $.Event( "pagebeforeload" ), + triggerData = { url: url, absUrl: absUrl, dataUrl: dataUrl, deferred: deferred, options: settings }; + + // Let listeners know we're about to load a page. + mpc.trigger( pblEvent, triggerData ); + + // If the default behavior is prevented, stop here! + if ( pblEvent.isDefaultPrevented() ) { + return deferred.promise(); + } + + if ( settings.showLoadMsg ) { + + // This configurable timeout allows cached pages a brief delay to load without showing a message + var loadMsgDelay = setTimeout(function() { + $.mobile.showPageLoadingMsg(); + }, settings.loadMsgDelay ), + + // Shared logic for clearing timeout and removing message. + hideMsg = function() { + + // Stop message show timer + clearTimeout( loadMsgDelay ); + + // Hide loading message + $.mobile.hidePageLoadingMsg(); + }; + } + // Reset base to the default document base. + // only reset if we are not prefetching + if ( base && typeof options.prefetch === "undefined" ) { + base.reset(); + } + + if ( !( $.mobile.allowCrossDomainPages || path.isSameDomain( documentUrl, absUrl ) ) ) { + deferred.reject( absUrl, options ); + } else { + // Load the new page. + $.ajax({ + url: fileUrl, + type: settings.type, + data: settings.data, + dataType: "html", + success: function( html, textStatus, xhr ) { + //pre-parse html to check for a data-url, + //use it as the new fileUrl, base path, etc + var all = $( "
" ), + + //page title regexp + newPageTitle = html.match( /]*>([^<]*)/ ) && RegExp.$1, + + // TODO handle dialogs again + pageElemRegex = new RegExp( "(<[^>]+\\bdata-" + $.mobile.ns + "role=[\"']?page[\"']?[^>]*>)" ), + dataUrlRegex = new RegExp( "\\bdata-" + $.mobile.ns + "url=[\"']?([^\"'>]*)[\"']?" ); + + + // data-url must be provided for the base tag so resource requests can be directed to the + // correct url. loading into a temprorary element makes these requests immediately + if ( pageElemRegex.test( html ) && + RegExp.$1 && + dataUrlRegex.test( RegExp.$1 ) && + RegExp.$1 ) { + url = fileUrl = path.getFilePath( $( "
" + RegExp.$1 + "
" ).text() ); + } + //dont update the base tag if we are prefetching + if ( base && typeof options.prefetch === "undefined") { + base.set( fileUrl ); + } + + //workaround to allow scripts to execute when included in page divs + all.get( 0 ).innerHTML = html; + page = all.find( ":jqmData(role='page'), :jqmData(role='dialog')" ).first(); + + //if page elem couldn't be found, create one and insert the body element's contents + if ( !page.length ) { + page = $( "
" + html.split( /<\/?body[^>]*>/gmi )[1] + "
" ); + } + + if ( newPageTitle && !page.jqmData( "title" ) ) { + if ( ~newPageTitle.indexOf( "&" ) ) { + newPageTitle = $( "
" + newPageTitle + "
" ).text(); + } + page.jqmData( "title", newPageTitle ); + } + + //rewrite src and href attrs to use a base url + if ( !$.support.dynamicBaseTag ) { + var newPath = path.get( fileUrl ); + page.find( "[src], link[href], a[rel='external'], :jqmData(ajax='false'), a[target]" ).each(function() { + var thisAttr = $( this ).is( '[href]' ) ? 'href' : + $( this ).is( '[src]' ) ? 'src' : 'action', + thisUrl = $( this ).attr( thisAttr ); + + // XXX_jblas: We need to fix this so that it removes the document + // base URL, and then prepends with the new page URL. + //if full path exists and is same, chop it - helps IE out + thisUrl = thisUrl.replace( location.protocol + '//' + location.host + location.pathname, '' ); + + if ( !/^(\w+:|#|\/)/.test( thisUrl ) ) { + $( this ).attr( thisAttr, newPath + thisUrl ); + } + }); + } + + //append to page and enhance + // TODO taging a page with external to make sure that embedded pages aren't removed + // by the various page handling code is bad. Having page handling code in many + // places is bad. Solutions post 1.0 + page + .attr( "data-" + $.mobile.ns + "url", path.convertUrlToDataUrl( fileUrl ) ) + .attr( "data-" + $.mobile.ns + "external-page", true ) + .appendTo( settings.pageContainer ); + + // wait for page creation to leverage options defined on widget + page.one( 'pagecreate', $.mobile._bindPageRemove ); + + enhancePage( page, settings.role ); + + // Enhancing the page may result in new dialogs/sub pages being inserted + // into the DOM. If the original absUrl refers to a sub-page, that is the + // real page we are interested in. + if ( absUrl.indexOf( "&" + $.mobile.subPageUrlKey ) > -1 ) { + page = settings.pageContainer.children( "[data-" + $.mobile.ns +"url='" + dataUrl + "']" ); + } + + //bind pageHide to removePage after it's hidden, if the page options specify to do so + + // Remove loading message. + if ( settings.showLoadMsg ) { + hideMsg(); + } + + // Add the page reference and xhr to our triggerData. + triggerData.xhr = xhr; + triggerData.textStatus = textStatus; + triggerData.page = page; + + // Let listeners know the page loaded successfully. + settings.pageContainer.trigger( "pageload", triggerData ); + + deferred.resolve( absUrl, options, page, dupCachedPage ); + }, + error: function( xhr, textStatus, errorThrown ) { + //set base back to current path + if ( base ) { + base.set( path.get() ); + } + + // Add error info to our triggerData. + triggerData.xhr = xhr; + triggerData.textStatus = textStatus; + triggerData.errorThrown = errorThrown; + + var plfEvent = new $.Event( "pageloadfailed" ); + + // Let listeners know the page load failed. + settings.pageContainer.trigger( plfEvent, triggerData ); + + // If the default behavior is prevented, stop here! + // Note that it is the responsibility of the listener/handler + // that called preventDefault(), to resolve/reject the + // deferred object within the triggerData. + if ( plfEvent.isDefaultPrevented() ) { + return; + } + + // Remove loading message. + if ( settings.showLoadMsg ) { + + // Remove loading message. + hideMsg(); + + // show error message + $.mobile.showPageLoadingMsg( $.mobile.pageLoadErrorMessageTheme, $.mobile.pageLoadErrorMessage, true ); + + // hide after delay + setTimeout( $.mobile.hidePageLoadingMsg, 1500 ); + } + + deferred.reject( absUrl, options ); + } + }); + } + + return deferred.promise(); + }; + + $.mobile.loadPage.defaults = { + type: "get", + data: undefined, + reloadPage: false, + role: undefined, // By default we rely on the role defined by the @data-role attribute. + showLoadMsg: false, + pageContainer: undefined, + loadMsgDelay: 50 // This delay allows loads that pull from browser cache to occur without showing the loading message. + }; + + // Show a specific page in the page container. + $.mobile.changePage = function( toPage, options ) { + // If we are in the midst of a transition, queue the current request. + // We'll call changePage() once we're done with the current transition to + // service the request. + if ( isPageTransitioning ) { + pageTransitionQueue.unshift( arguments ); + return; + } + + var settings = $.extend( {}, $.mobile.changePage.defaults, options ); + + // Make sure we have a pageContainer to work with. + settings.pageContainer = settings.pageContainer || $.mobile.pageContainer; + + // Make sure we have a fromPage. + settings.fromPage = settings.fromPage || $.mobile.activePage; + + var mpc = settings.pageContainer, + pbcEvent = new $.Event( "pagebeforechange" ), + triggerData = { toPage: toPage, options: settings }; + + // Let listeners know we're about to change the current page. + mpc.trigger( pbcEvent, triggerData ); + + // If the default behavior is prevented, stop here! + if ( pbcEvent.isDefaultPrevented() ) { + return; + } + + // We allow "pagebeforechange" observers to modify the toPage in the trigger + // data to allow for redirects. Make sure our toPage is updated. + + toPage = triggerData.toPage; + + // Set the isPageTransitioning flag to prevent any requests from + // entering this method while we are in the midst of loading a page + // or transitioning. + + isPageTransitioning = true; + + // If the caller passed us a url, call loadPage() + // to make sure it is loaded into the DOM. We'll listen + // to the promise object it returns so we know when + // it is done loading or if an error ocurred. + if ( typeof toPage === "string" ) { + $.mobile.loadPage( toPage, settings ) + .done(function( url, options, newPage, dupCachedPage ) { + isPageTransitioning = false; + options.duplicateCachedPage = dupCachedPage; + $.mobile.changePage( newPage, options ); + }) + .fail(function( url, options ) { + + //clear out the active button state + removeActiveLinkClass( true ); + + //release transition lock so navigation is free again + releasePageTransitionLock(); + settings.pageContainer.trigger( "pagechangefailed", triggerData ); + }); + return; + } + + // If we are going to the first-page of the application, we need to make + // sure settings.dataUrl is set to the application document url. This allows + // us to avoid generating a document url with an id hash in the case where the + // first-page of the document has an id attribute specified. + if ( toPage[ 0 ] === $.mobile.firstPage[ 0 ] && !settings.dataUrl ) { + settings.dataUrl = documentUrl.hrefNoHash; + } + + // The caller passed us a real page DOM element. Update our + // internal state and then trigger a transition to the page. + var fromPage = settings.fromPage, + url = ( settings.dataUrl && path.convertUrlToDataUrl( settings.dataUrl ) ) || toPage.jqmData( "url" ), + // The pageUrl var is usually the same as url, except when url is obscured as a dialog url. pageUrl always contains the file path + pageUrl = url, + fileUrl = path.getFilePath( url ), + active = urlHistory.getActive(), + activeIsInitialPage = urlHistory.activeIndex === 0, + historyDir = 0, + pageTitle = document.title, + isDialog = settings.role === "dialog" || toPage.jqmData( "role" ) === "dialog"; + + // By default, we prevent changePage requests when the fromPage and toPage + // are the same element, but folks that generate content manually/dynamically + // and reuse pages want to be able to transition to the same page. To allow + // this, they will need to change the default value of allowSamePageTransition + // to true, *OR*, pass it in as an option when they manually call changePage(). + // It should be noted that our default transition animations assume that the + // formPage and toPage are different elements, so they may behave unexpectedly. + // It is up to the developer that turns on the allowSamePageTransitiona option + // to either turn off transition animations, or make sure that an appropriate + // animation transition is used. + if ( fromPage && fromPage[0] === toPage[0] && !settings.allowSamePageTransition ) { + isPageTransitioning = false; + mpc.trigger( "pagechange", triggerData ); + + // Even if there is no page change to be done, we should keep the urlHistory in sync with the hash changes + if ( settings.fromHashChange ) { + urlHistory.directHashChange({ + currentUrl: url, + isBack: function() {}, + isForward: function() {} + }); + } + + return; + } + + // We need to make sure the page we are given has already been enhanced. + enhancePage( toPage, settings.role ); + + // If the changePage request was sent from a hashChange event, check to see if the + // page is already within the urlHistory stack. If so, we'll assume the user hit + // the forward/back button and will try to match the transition accordingly. + if ( settings.fromHashChange ) { + urlHistory.directHashChange({ + currentUrl: url, + isBack: function() { historyDir = -1; }, + isForward: function() { historyDir = 1; } + }); + } + + // Kill the keyboard. + // XXX_jblas: We need to stop crawling the entire document to kill focus. Instead, + // we should be tracking focus with a delegate() handler so we already have + // the element in hand at this point. + // Wrap this in a try/catch block since IE9 throw "Unspecified error" if document.activeElement + // is undefined when we are in an IFrame. + try { + if ( document.activeElement && document.activeElement.nodeName.toLowerCase() !== 'body' ) { + $( document.activeElement ).blur(); + } else { + $( "input:focus, textarea:focus, select:focus" ).blur(); + } + } catch( e ) {} + + // Record whether we are at a place in history where a dialog used to be - if so, do not add a new history entry and do not change the hash either + var alreadyThere = false; + + // If we're displaying the page as a dialog, we don't want the url + // for the dialog content to be used in the hash. Instead, we want + // to append the dialogHashKey to the url of the current page. + if ( isDialog && active ) { + // on the initial page load active.url is undefined and in that case should + // be an empty string. Moving the undefined -> empty string back into + // urlHistory.addNew seemed imprudent given undefined better represents + // the url state + + // If we are at a place in history that once belonged to a dialog, reuse + // this state without adding to urlHistory and without modifying the hash. + // However, if a dialog is already displayed at this point, and we're + // about to display another dialog, then we must add another hash and + // history entry on top so that one may navigate back to the original dialog + if ( active.url && active.url.indexOf( dialogHashKey ) > -1 && !$.mobile.activePage.is( ".ui-dialog" ) ) { + settings.changeHash = false; + alreadyThere = true; + } + + // Normally, we tack on a dialog hash key, but if this is the location of a stale dialog, + // we reuse the URL from the entry + url = ( active.url || "" ) + ( alreadyThere ? "" : dialogHashKey ); + + // tack on another dialogHashKey if this is the same as the initial hash + // this makes sure that a history entry is created for this dialog + if ( urlHistory.activeIndex === 0 && url === urlHistory.initialDst ) { + url += dialogHashKey; + } + } + + // Set the location hash. + if ( settings.changeHash !== false && url ) { + //disable hash listening temporarily + urlHistory.ignoreNextHashChange = true; + //update hash and history + path.set( url ); + } + + // if title element wasn't found, try the page div data attr too + // If this is a deep-link or a reload ( active === undefined ) then just use pageTitle + var newPageTitle = ( !active )? pageTitle : toPage.jqmData( "title" ) || toPage.children( ":jqmData(role='header')" ).find( ".ui-title" ).getEncodedText(); + if ( !!newPageTitle && pageTitle === document.title ) { + pageTitle = newPageTitle; + } + if ( !toPage.jqmData( "title" ) ) { + toPage.jqmData( "title", pageTitle ); + } + + // Make sure we have a transition defined. + settings.transition = settings.transition || + ( ( historyDir && !activeIsInitialPage ) ? active.transition : undefined ) || + ( isDialog ? $.mobile.defaultDialogTransition : $.mobile.defaultPageTransition ); + + //add page to history stack if it's not back or forward + if ( !historyDir ) { + // Overwrite the current entry if it's a leftover from a dialog + if ( alreadyThere ) { + urlHistory.activeIndex = Math.max( 0, urlHistory.activeIndex - 1 ); + } + urlHistory.addNew( url, settings.transition, pageTitle, pageUrl, settings.role ); + } + + //set page title + document.title = urlHistory.getActive().title; + + //set "toPage" as activePage + $.mobile.activePage = toPage; + + // If we're navigating back in the URL history, set reverse accordingly. + settings.reverse = settings.reverse || historyDir < 0; + + transitionPages( toPage, fromPage, settings.transition, settings.reverse ) + .done(function( name, reverse, $to, $from, alreadyFocused ) { + removeActiveLinkClass(); + + //if there's a duplicateCachedPage, remove it from the DOM now that it's hidden + if ( settings.duplicateCachedPage ) { + settings.duplicateCachedPage.remove(); + } + + // Send focus to the newly shown page. Moved from promise .done binding in transitionPages + // itself to avoid ie bug that reports offsetWidth as > 0 (core check for visibility) + // despite visibility: hidden addresses issue #2965 + // https://github.com/jquery/jquery-mobile/issues/2965 + if ( !alreadyFocused ) { + $.mobile.focusPage( toPage ); + } + + releasePageTransitionLock(); + + // Let listeners know we're all done changing the current page. + mpc.trigger( "pagechange", triggerData ); + }); + }; + + $.mobile.changePage.defaults = { + transition: undefined, + reverse: false, + changeHash: true, + fromHashChange: false, + role: undefined, // By default we rely on the role defined by the @data-role attribute. + duplicateCachedPage: undefined, + pageContainer: undefined, + showLoadMsg: true, //loading message shows by default when pages are being fetched during changePage + dataUrl: undefined, + fromPage: undefined, + allowSamePageTransition: false + }; + +/* Event Bindings - hashchange, submit, and click */ + function findClosestLink( ele ) + { + while ( ele ) { + // Look for the closest element with a nodeName of "a". + // Note that we are checking if we have a valid nodeName + // before attempting to access it. This is because the + // node we get called with could have originated from within + // an embedded SVG document where some symbol instance elements + // don't have nodeName defined on them, or strings are of type + // SVGAnimatedString. + if ( ( typeof ele.nodeName === "string" ) && ele.nodeName.toLowerCase() === "a" ) { + break; + } + ele = ele.parentNode; + } + return ele; + } + + // The base URL for any given element depends on the page it resides in. + function getClosestBaseUrl( ele ) + { + // Find the closest page and extract out its url. + var url = $( ele ).closest( ".ui-page" ).jqmData( "url" ), + base = documentBase.hrefNoHash; + + if ( !url || !path.isPath( url ) ) { + url = base; + } + + return path.makeUrlAbsolute( url, base); + } + + //The following event bindings should be bound after mobileinit has been triggered + //the following deferred is resolved in the init file + $.mobile.navreadyDeferred = $.Deferred(); + $.mobile._registerInternalEvents = function() { + //bind to form submit events, handle with Ajax + $( document ).delegate( "form", "submit", function( event ) { + var $this = $( this ); + + if ( !$.mobile.ajaxEnabled || + // test that the form is, itself, ajax false + $this.is( ":jqmData(ajax='false')" ) || + // test that $.mobile.ignoreContentEnabled is set and + // the form or one of it's parents is ajax=false + !$this.jqmHijackable().length ) { + return; + } + + var type = $this.attr( "method" ), + target = $this.attr( "target" ), + url = $this.attr( "action" ); + + // If no action is specified, browsers default to using the + // URL of the document containing the form. Since we dynamically + // pull in pages from external documents, the form should submit + // to the URL for the source document of the page containing + // the form. + if ( !url ) { + // Get the @data-url for the page containing the form. + url = getClosestBaseUrl( $this ); + if ( url === documentBase.hrefNoHash ) { + // The url we got back matches the document base, + // which means the page must be an internal/embedded page, + // so default to using the actual document url as a browser + // would. + url = documentUrl.hrefNoSearch; + } + } + + url = path.makeUrlAbsolute( url, getClosestBaseUrl( $this ) ); + + if ( ( path.isExternal( url ) && !path.isPermittedCrossDomainRequest( documentUrl, url ) ) || target ) { + return; + } + + $.mobile.changePage( + url, + { + type: type && type.length && type.toLowerCase() || "get", + data: $this.serialize(), + transition: $this.jqmData( "transition" ), + reverse: $this.jqmData( "direction" ) === "reverse", + reloadPage: true + } + ); + event.preventDefault(); + }); + + //add active state on vclick + $( document ).bind( "vclick", function( event ) { + // if this isn't a left click we don't care. Its important to note + // that when the virtual event is generated it will create the which attr + if ( event.which > 1 || !$.mobile.linkBindingEnabled ) { + return; + } + + var link = findClosestLink( event.target ); + + // split from the previous return logic to avoid find closest where possible + // TODO teach $.mobile.hijackable to operate on raw dom elements so the link wrapping + // can be avoided + if ( !$( link ).jqmHijackable().length ) { + return; + } + + if ( link ) { + if ( path.parseUrl( link.getAttribute( "href" ) || "#" ).hash !== "#" ) { + removeActiveLinkClass( true ); + $activeClickedLink = $( link ).closest( ".ui-btn" ).not( ".ui-disabled" ); + $activeClickedLink.addClass( $.mobile.activeBtnClass ); + } + } + }); + + // click routing - direct to HTTP or Ajax, accordingly + $( document ).bind( "click", function( event ) { + if ( !$.mobile.linkBindingEnabled ) { + return; + } + + var link = findClosestLink( event.target ), $link = $( link ), httpCleanup; + + // If there is no link associated with the click or its not a left + // click we want to ignore the click + // TODO teach $.mobile.hijackable to operate on raw dom elements so the link wrapping + // can be avoided + if ( !link || event.which > 1 || !$link.jqmHijackable().length ) { + return; + } + + //remove active link class if external (then it won't be there if you come back) + httpCleanup = function() { + window.setTimeout(function() { removeActiveLinkClass( true ); }, 200 ); + }; + + //if there's a data-rel=back attr, go back in history + if ( $link.is( ":jqmData(rel='back')" ) ) { + $.mobile.back(); + return false; + } + + var baseUrl = getClosestBaseUrl( $link ), + + //get href, if defined, otherwise default to empty hash + href = path.makeUrlAbsolute( $link.attr( "href" ) || "#", baseUrl ); + + //if ajax is disabled, exit early + if ( !$.mobile.ajaxEnabled && !path.isEmbeddedPage( href ) ) { + httpCleanup(); + //use default click handling + return; + } + + // XXX_jblas: Ideally links to application pages should be specified as + // an url to the application document with a hash that is either + // the site relative path or id to the page. But some of the + // internal code that dynamically generates sub-pages for nested + // lists and select dialogs, just write a hash in the link they + // create. This means the actual URL path is based on whatever + // the current value of the base tag is at the time this code + // is called. For now we are just assuming that any url with a + // hash in it is an application page reference. + if ( href.search( "#" ) !== -1 ) { + href = href.replace( /[^#]*#/, "" ); + if ( !href ) { + //link was an empty hash meant purely + //for interaction, so we ignore it. + event.preventDefault(); + return; + } else if ( path.isPath( href ) ) { + //we have apath so make it the href we want to load. + href = path.makeUrlAbsolute( href, baseUrl ); + } else { + //we have a simple id so use the documentUrl as its base. + href = path.makeUrlAbsolute( "#" + href, documentUrl.hrefNoHash ); + } + } + + // Should we handle this link, or let the browser deal with it? + var useDefaultUrlHandling = $link.is( "[rel='external']" ) || $link.is( ":jqmData(ajax='false')" ) || $link.is( "[target]" ), + + // Some embedded browsers, like the web view in Phone Gap, allow cross-domain XHR + // requests if the document doing the request was loaded via the file:// protocol. + // This is usually to allow the application to "phone home" and fetch app specific + // data. We normally let the browser handle external/cross-domain urls, but if the + // allowCrossDomainPages option is true, we will allow cross-domain http/https + // requests to go through our page loading logic. + + //check for protocol or rel and its not an embedded page + //TODO overlap in logic from isExternal, rel=external check should be + // moved into more comprehensive isExternalLink + isExternal = useDefaultUrlHandling || ( path.isExternal( href ) && !path.isPermittedCrossDomainRequest( documentUrl, href ) ); + + if ( isExternal ) { + httpCleanup(); + //use default click handling + return; + } + + //use ajax + var transition = $link.jqmData( "transition" ), + reverse = $link.jqmData( "direction" ) === "reverse" || + // deprecated - remove by 1.0 + $link.jqmData( "back" ), + + //this may need to be more specific as we use data-rel more + role = $link.attr( "data-" + $.mobile.ns + "rel" ) || undefined; + + $.mobile.changePage( href, { transition: transition, reverse: reverse, role: role, link: $link } ); + event.preventDefault(); + }); + + //prefetch pages when anchors with data-prefetch are encountered + $( document ).delegate( ".ui-page", "pageshow.prefetch", function() { + var urls = []; + $( this ).find( "a:jqmData(prefetch)" ).each(function() { + var $link = $( this ), + url = $link.attr( "href" ); + + if ( url && $.inArray( url, urls ) === -1 ) { + urls.push( url ); + + $.mobile.loadPage( url, { role: $link.attr( "data-" + $.mobile.ns + "rel" ),prefetch: true } ); + } + }); + }); + + $.mobile._handleHashChange = function( hash ) { + //find first page via hash + var to = path.stripHash( hash ), + //transition is false if it's the first page, undefined otherwise (and may be overridden by default) + transition = $.mobile.urlHistory.stack.length === 0 ? "none" : undefined, + + // "navigate" event fired to allow others to take advantage of the more robust hashchange handling + navEvent = new $.Event( "navigate" ), + + // default options for the changPage calls made after examining the current state + // of the page and the hash + changePageOptions = { + transition: transition, + changeHash: false, + fromHashChange: true + }; + + if ( 0 === urlHistory.stack.length ) { + urlHistory.initialDst = to; + } + + // We should probably fire the "navigate" event from those places that make calls to _handleHashChange, + // and have _handleHashChange hook into the "navigate" event instead of triggering it here + $.mobile.pageContainer.trigger( navEvent ); + if ( navEvent.isDefaultPrevented() ) { + return; + } + + //if listening is disabled (either globally or temporarily), or it's a dialog hash + if ( !$.mobile.hashListeningEnabled || urlHistory.ignoreNextHashChange ) { + urlHistory.ignoreNextHashChange = false; + return; + } + + // special case for dialogs + if ( urlHistory.stack.length > 1 && to.indexOf( dialogHashKey ) > -1 && urlHistory.initialDst !== to ) { + + // If current active page is not a dialog skip the dialog and continue + // in the same direction + if ( !$.mobile.activePage.is( ".ui-dialog" ) ) { + //determine if we're heading forward or backward and continue accordingly past + //the current dialog + urlHistory.directHashChange({ + currentUrl: to, + isBack: function() { $.mobile.back(); }, + isForward: function() { window.history.forward(); } + }); + + // prevent changePage() + return; + } else { + // if the current active page is a dialog and we're navigating + // to a dialog use the dialog objected saved in the stack + urlHistory.directHashChange({ + currentUrl: to, + + // regardless of the direction of the history change + // do the following + either: function( isBack ) { + var active = $.mobile.urlHistory.getActive(); + + to = active.pageUrl; + + // make sure to set the role, transition and reversal + // as most of this is lost by the domCache cleaning + $.extend( changePageOptions, { + role: active.role, + transition: active.transition, + reverse: isBack + }); + } + }); + } + } + + //if to is defined, load it + if ( to ) { + // At this point, 'to' can be one of 3 things, a cached page element from + // a history stack entry, an id, or site-relative/absolute URL. If 'to' is + // an id, we need to resolve it against the documentBase, not the location.href, + // since the hashchange could've been the result of a forward/backward navigation + // that crosses from an external page/dialog to an internal page/dialog. + to = ( typeof to === "string" && !path.isPath( to ) ) ? ( path.makeUrlAbsolute( '#' + to, documentBase ) ) : to; + + // If we're about to go to an initial URL that contains a reference to a non-existent + // internal page, go to the first page instead. We know that the initial hash refers to a + // non-existent page, because the initial hash did not end up in the initial urlHistory entry + if ( to === path.makeUrlAbsolute( '#' + urlHistory.initialDst, documentBase ) && + urlHistory.stack.length && urlHistory.stack[0].url !== urlHistory.initialDst.replace( dialogHashKey, "" ) ) { + to = $.mobile.firstPage; + } + $.mobile.changePage( to, changePageOptions ); + } else { + //there's no hash, go to the first page in the dom + $.mobile.changePage( $.mobile.firstPage, changePageOptions ); + } + }; + + //hashchange event handler + $window.bind( "hashchange", function( e, triggered ) { + // Firefox auto-escapes the location.hash as for v13 but + // leaves the href untouched + $.mobile._handleHashChange( path.parseLocation().hash ); + }); + + //set page min-heights to be device specific + $( document ).bind( "pageshow", resetActivePageHeight ); + $( window ).bind( "throttledresize", resetActivePageHeight ); + + };//navreadyDeferred done callback + $.mobile.navreadyDeferred.done( function() { $.mobile._registerInternalEvents(); } ); + +})( jQuery ); + +(function( $, window ) { + // For now, let's Monkeypatch this onto the end of $.mobile._registerInternalEvents + // Scope self to pushStateHandler so we can reference it sanely within the + // methods handed off as event handlers + var pushStateHandler = {}, + self = pushStateHandler, + $win = $( window ), + url = $.mobile.path.parseLocation(), + mobileinitDeferred = $.Deferred(), + domreadyDeferred = $.Deferred(); + + $( document ).ready( $.proxy( domreadyDeferred, "resolve" ) ); + + $( document ).one( "mobileinit", $.proxy( mobileinitDeferred, "resolve" ) ); + + $.extend( pushStateHandler, { + // TODO move to a path helper, this is rather common functionality + initialFilePath: (function() { + return url.pathname + url.search; + })(), + + hashChangeTimeout: 200, + + hashChangeEnableTimer: undefined, + + initialHref: url.hrefNoHash, + + state: function() { + return { + // firefox auto decodes the url when using location.hash but not href + hash: $.mobile.path.parseLocation().hash || "#" + self.initialFilePath, + title: document.title, + + // persist across refresh + initialHref: self.initialHref + }; + }, + + resetUIKeys: function( url ) { + var dialog = $.mobile.dialogHashKey, + subkey = "&" + $.mobile.subPageUrlKey, + dialogIndex = url.indexOf( dialog ); + + if ( dialogIndex > -1 ) { + url = url.slice( 0, dialogIndex ) + "#" + url.slice( dialogIndex ); + } else if ( url.indexOf( subkey ) > -1 ) { + url = url.split( subkey ).join( "#" + subkey ); + } + + return url; + }, + + // TODO sort out a single barrier to hashchange functionality + nextHashChangePrevented: function( value ) { + $.mobile.urlHistory.ignoreNextHashChange = value; + self.onHashChangeDisabled = value; + }, + + // on hash change we want to clean up the url + // NOTE this takes place *after* the vanilla navigation hash change + // handling has taken place and set the state of the DOM + onHashChange: function( e ) { + // disable this hash change + if ( self.onHashChangeDisabled ) { + return; + } + + var href, state, + // firefox auto decodes the url when using location.hash but not href + hash = $.mobile.path.parseLocation().hash, + isPath = $.mobile.path.isPath( hash ), + resolutionUrl = isPath ? $.mobile.path.getLocation() : $.mobile.getDocumentUrl(); + + hash = isPath ? hash.replace( "#", "" ) : hash; + + + // propulate the hash when its not available + state = self.state(); + + // make the hash abolute with the current href + href = $.mobile.path.makeUrlAbsolute( hash, resolutionUrl ); + + if ( isPath ) { + href = self.resetUIKeys( href ); + } + + // replace the current url with the new href and store the state + // Note that in some cases we might be replacing an url with the + // same url. We do this anyways because we need to make sure that + // all of our history entries have a state object associated with + // them. This allows us to work around the case where $.mobile.back() + // is called to transition from an external page to an embedded page. + // In that particular case, a hashchange event is *NOT* generated by the browser. + // Ensuring each history entry has a state object means that onPopState() + // will always trigger our hashchange callback even when a hashchange event + // is not fired. + history.replaceState( state, document.title, href ); + }, + + // on popstate (ie back or forward) we need to replace the hash that was there previously + // cleaned up by the additional hash handling + onPopState: function( e ) { + var poppedState = e.originalEvent.state, + fromHash, toHash, hashChanged; + + // if there's no state its not a popstate we care about, eg chrome's initial popstate + if ( poppedState ) { + // if we get two pop states in under this.hashChangeTimeout + // make sure to clear any timer set for the previous change + clearTimeout( self.hashChangeEnableTimer ); + + // make sure to enable hash handling for the the _handleHashChange call + self.nextHashChangePrevented( false ); + + // change the page based on the hash in the popped state + $.mobile._handleHashChange( poppedState.hash ); + + // prevent any hashchange in the next self.hashChangeTimeout + self.nextHashChangePrevented( true ); + + // re-enable hash change handling after swallowing a possible hash + // change event that comes on all popstates courtesy of browsers like Android + self.hashChangeEnableTimer = setTimeout( function() { + self.nextHashChangePrevented( false ); + }, self.hashChangeTimeout ); + } + }, + + init: function() { + $win.bind( "hashchange", self.onHashChange ); + + // Handle popstate events the occur through history changes + $win.bind( "popstate", self.onPopState ); + + // if there's no hash, we need to replacestate for returning to home + if ( location.hash === "" ) { + history.replaceState( self.state(), document.title, $.mobile.path.getLocation() ); + } + } + }); + + // We need to init when "mobileinit", "domready", and "navready" have all happened + $.when( domreadyDeferred, mobileinitDeferred, $.mobile.navreadyDeferred ).done(function() { + if ( $.mobile.pushStateEnabled && $.support.pushState ) { + pushStateHandler.init(); + } + }); +})( jQuery, this ); + +/* +* fallback transition for flip in non-3D supporting browsers (which tend to handle complex transitions poorly in general +*/ + +(function( $, window, undefined ) { + +$.mobile.transitionFallbacks.flip = "fade"; + +})( jQuery, this ); +/* +* fallback transition for flow in non-3D supporting browsers (which tend to handle complex transitions poorly in general +*/ + +(function( $, window, undefined ) { + +$.mobile.transitionFallbacks.flow = "fade"; + +})( jQuery, this ); +/* +* fallback transition for pop in non-3D supporting browsers (which tend to handle complex transitions poorly in general +*/ + +(function( $, window, undefined ) { + +$.mobile.transitionFallbacks.pop = "fade"; + +})( jQuery, this ); +/* +* fallback transition for slide in non-3D supporting browsers (which tend to handle complex transitions poorly in general +*/ + +(function( $, window, undefined ) { + +// Use the simultaneous transitions handler for slide transitions +$.mobile.transitionHandlers.slide = $.mobile.transitionHandlers.simultaneous; + +// Set the slide transitions's fallback to "fade" +$.mobile.transitionFallbacks.slide = "fade"; + +})( jQuery, this ); +/* +* fallback transition for slidedown in non-3D supporting browsers (which tend to handle complex transitions poorly in general +*/ + +(function( $, window, undefined ) { + +$.mobile.transitionFallbacks.slidedown = "fade"; + +})( jQuery, this ); +/* +* fallback transition for slidefade in non-3D supporting browsers (which tend to handle complex transitions poorly in general +*/ + +(function( $, window, undefined ) { + +// Set the slide transitions's fallback to "fade" +$.mobile.transitionFallbacks.slidefade = "fade"; + +})( jQuery, this ); +/* +* fallback transition for slideup in non-3D supporting browsers (which tend to handle complex transitions poorly in general +*/ + +(function( $, window, undefined ) { + +$.mobile.transitionFallbacks.slideup = "fade"; + +})( jQuery, this ); +/* +* fallback transition for turn in non-3D supporting browsers (which tend to handle complex transitions poorly in general +*/ + +(function( $, window, undefined ) { + +$.mobile.transitionFallbacks.turn = "fade"; + +})( jQuery, this ); + +(function( $, undefined ) { + +$.mobile.page.prototype.options.degradeInputs = { + color: false, + date: false, + datetime: false, + "datetime-local": false, + email: false, + month: false, + number: false, + range: "number", + search: "text", + tel: false, + time: false, + url: false, + week: false +}; + + +//auto self-init widgets +$( document ).bind( "pagecreate create", function( e ) { + + var page = $.mobile.closestPageData( $( e.target ) ), options; + + if ( !page ) { + return; + } + + options = page.options; + + // degrade inputs to avoid poorly implemented native functionality + $( e.target ).find( "input" ).not( page.keepNativeSelector() ).each(function() { + var $this = $( this ), + type = this.getAttribute( "type" ), + optType = options.degradeInputs[ type ] || "text"; + + if ( options.degradeInputs[ type ] ) { + var html = $( "
" ).html( $this.clone() ).html(), + // In IE browsers, the type sometimes doesn't exist in the cloned markup, so we replace the closing tag instead + hasType = html.indexOf( " type=" ) > -1, + findstr = hasType ? /\s+type=["']?\w+['"]?/ : /\/?>/, + repstr = " type=\"" + optType + "\" data-" + $.mobile.ns + "type=\"" + type + "\"" + ( hasType ? "" : ">" ); + + $this.replaceWith( html.replace( findstr, repstr ) ); + } + }); + +}); + +})( jQuery ); + +(function( $, window, undefined ) { + +$.widget( "mobile.dialog", $.mobile.widget, { + options: { + closeBtnText: "Close", + overlayTheme: "a", + initSelector: ":jqmData(role='dialog')" + }, + _create: function() { + var self = this, + $el = this.element, + headerCloseButton = $( ""+ this.options.closeBtnText + "" ), + dialogWrap = $( "
", { + "role" : "dialog", + "class" : "ui-dialog-contain ui-corner-all ui-overlay-shadow" + }); + + $el.addClass( "ui-dialog ui-overlay-" + this.options.overlayTheme ); + + // Class the markup for dialog styling + // Set aria role + $el + .wrapInner( dialogWrap ) + .children() + .find( ":jqmData(role='header')" ).first() + .prepend( headerCloseButton ) + .end().end() + .children( ':first-child') + .addClass( "ui-corner-top" ) + .end() + .children( ":last-child" ) + .addClass( "ui-corner-bottom" ); + + // this must be an anonymous function so that select menu dialogs can replace + // the close method. This is a change from previously just defining data-rel=back + // on the button and letting nav handle it + // + // Use click rather than vclick in order to prevent the possibility of unintentionally + // reopening the dialog if the dialog opening item was directly under the close button. + headerCloseButton.bind( "click", function() { + self.close(); + }); + + /* bind events + - clicks and submits should use the closing transition that the dialog opened with + unless a data-transition is specified on the link/form + - if the click was on the close button, or the link has a data-rel="back" it'll go back in history naturally + */ + $el.bind( "vclick submit", function( event ) { + var $target = $( event.target ).closest( event.type === "vclick" ? "a" : "form" ), + active; + + if ( $target.length && !$target.jqmData( "transition" ) ) { + + active = $.mobile.urlHistory.getActive() || {}; + + $target.attr( "data-" + $.mobile.ns + "transition", ( active.transition || $.mobile.defaultDialogTransition ) ) + .attr( "data-" + $.mobile.ns + "direction", "reverse" ); + } + }) + .bind( "pagehide", function( e, ui ) { + $( this ).find( "." + $.mobile.activeBtnClass ).not( ".ui-slider-bg" ).removeClass( $.mobile.activeBtnClass ); + }) + // Override the theme set by the page plugin on pageshow + .bind( "pagebeforeshow", function() { + self._isCloseable = true; + if ( self.options.overlayTheme ) { + self.element + .page( "removeContainerBackground" ) + .page( "setContainerBackground", self.options.overlayTheme ); + } + }); + }, + + // Close method goes back in history + close: function() { + var dst; + + if ( this._isCloseable ) { + this._isCloseable = false; + if ( $.mobile.hashListeningEnabled ) { + $.mobile.back(); + } else { + dst = $.mobile.urlHistory.getPrev().url; + if ( !$.mobile.path.isPath( dst ) ) { + dst = $.mobile.path.makeUrlAbsolute( "#" + dst ); + } + + $.mobile.changePage( dst, { changeHash: false, fromHashChange: true } ); + } + } + } +}); + +//auto self-init widgets +$( document ).delegate( $.mobile.dialog.prototype.options.initSelector, "pagecreate", function() { + $.mobile.dialog.prototype.enhance( this ); +}); + +})( jQuery, this ); + +(function( $, undefined ) { + +$.mobile.page.prototype.options.backBtnText = "Back"; +$.mobile.page.prototype.options.addBackBtn = false; +$.mobile.page.prototype.options.backBtnTheme = null; +$.mobile.page.prototype.options.headerTheme = "a"; +$.mobile.page.prototype.options.footerTheme = "a"; +$.mobile.page.prototype.options.contentTheme = null; + +// NOTE bind used to force this binding to run before the buttonMarkup binding +// which expects .ui-footer top be applied in its gigantic selector +// TODO remove the buttonMarkup giant selector and move it to the various modules +// on which it depends +$( document ).bind( "pagecreate", function( e ) { + var $page = $( e.target ), + o = $page.data( "page" ).options, + pageRole = $page.jqmData( "role" ), + pageTheme = o.theme; + + $( ":jqmData(role='header'), :jqmData(role='footer'), :jqmData(role='content')", $page ) + .jqmEnhanceable() + .each(function() { + + var $this = $( this ), + role = $this.jqmData( "role" ), + theme = $this.jqmData( "theme" ), + contentTheme = theme || o.contentTheme || ( pageRole === "dialog" && pageTheme ), + $headeranchors, + leftbtn, + rightbtn, + backBtn; + + $this.addClass( "ui-" + role ); + + //apply theming and markup modifications to page,header,content,footer + if ( role === "header" || role === "footer" ) { + + var thisTheme = theme || ( role === "header" ? o.headerTheme : o.footerTheme ) || pageTheme; + + $this + //add theme class + .addClass( "ui-bar-" + thisTheme ) + // Add ARIA role + .attr( "role", role === "header" ? "banner" : "contentinfo" ); + + if ( role === "header") { + // Right,left buttons + $headeranchors = $this.children( "a, button" ); + leftbtn = $headeranchors.hasClass( "ui-btn-left" ); + rightbtn = $headeranchors.hasClass( "ui-btn-right" ); + + leftbtn = leftbtn || $headeranchors.eq( 0 ).not( ".ui-btn-right" ).addClass( "ui-btn-left" ).length; + + rightbtn = rightbtn || $headeranchors.eq( 1 ).addClass( "ui-btn-right" ).length; + } + + // Auto-add back btn on pages beyond first view + if ( o.addBackBtn && + role === "header" && + $( ".ui-page" ).length > 1 && + $page.jqmData( "url" ) !== $.mobile.path.stripHash( location.hash ) && + !leftbtn ) { + + backBtn = $( ""+ o.backBtnText +"" ) + // If theme is provided, override default inheritance + .attr( "data-"+ $.mobile.ns +"theme", o.backBtnTheme || thisTheme ) + .prependTo( $this ); + } + + // Page title + $this.children( "h1, h2, h3, h4, h5, h6" ) + .addClass( "ui-title" ) + // Regardless of h element number in src, it becomes h1 for the enhanced page + .attr({ + "role": "heading", + "aria-level": "1" + }); + + } else if ( role === "content" ) { + if ( contentTheme ) { + $this.addClass( "ui-body-" + ( contentTheme ) ); + } + + // Add ARIA role + $this.attr( "role", "main" ); + } + }); +}); + +})( jQuery ); + +(function( $, undefined ) { + +// filter function removes whitespace between label and form element so we can use inline-block (nodeType 3 = text) +$.fn.fieldcontain = function( options ) { + return this + .addClass( "ui-field-contain ui-body ui-br" ) + .contents().filter( function() { + return ( this.nodeType === 3 && !/\S/.test( this.nodeValue ) ); + }).remove(); +}; + +//auto self-init widgets +$( document ).bind( "pagecreate create", function( e ) { + $( ":jqmData(role='fieldcontain')", e.target ).jqmEnhanceable().fieldcontain(); +}); + +})( jQuery ); + +(function( $, undefined ) { + +$.fn.grid = function( options ) { + return this.each(function() { + + var $this = $( this ), + o = $.extend({ + grid: null + }, options ), + $kids = $this.children(), + gridCols = { solo:1, a:2, b:3, c:4, d:5 }, + grid = o.grid, + iterator; + + if ( !grid ) { + if ( $kids.length <= 5 ) { + for ( var letter in gridCols ) { + if ( gridCols[ letter ] === $kids.length ) { + grid = letter; + } + } + } else { + grid = "a"; + $this.addClass( "ui-grid-duo" ); + } + } + iterator = gridCols[grid]; + + $this.addClass( "ui-grid-" + grid ); + + $kids.filter( ":nth-child(" + iterator + "n+1)" ).addClass( "ui-block-a" ); + + if ( iterator > 1 ) { + $kids.filter( ":nth-child(" + iterator + "n+2)" ).addClass( "ui-block-b" ); + } + if ( iterator > 2 ) { + $kids.filter( ":nth-child(" + iterator + "n+3)" ).addClass( "ui-block-c" ); + } + if ( iterator > 3 ) { + $kids.filter( ":nth-child(" + iterator + "n+4)" ).addClass( "ui-block-d" ); + } + if ( iterator > 4 ) { + $kids.filter( ":nth-child(" + iterator + "n+5)" ).addClass( "ui-block-e" ); + } + }); +}; +})( jQuery ); + +(function( $, undefined ) { + +$( document ).bind( "pagecreate create", function( e ) { + $( ":jqmData(role='nojs')", e.target ).addClass( "ui-nojs" ); + +}); + +})( jQuery ); + +(function( $, undefined ) { + +$.mobile.behaviors.formReset = { + _handleFormReset: function() { + this._on( this.element.closest( "form" ), { + reset: function() { + this._delay( "_reset" ); + } + }); + } +}; + +})( jQuery ); + +(function( $, undefined ) { + +$.fn.buttonMarkup = function( options ) { + var $workingSet = this, + mapToDataAttr = function( key, value ) { + e.setAttribute( "data-" + $.mobile.ns + key, value ); + el.jqmData( key, value ); + }; + + // Enforce options to be of type string + options = ( options && ( $.type( options ) === "object" ) )? options : {}; + for ( var i = 0; i < $workingSet.length; i++ ) { + var el = $workingSet.eq( i ), + e = el[ 0 ], + o = $.extend( {}, $.fn.buttonMarkup.defaults, { + icon: options.icon !== undefined ? options.icon : el.jqmData( "icon" ), + iconpos: options.iconpos !== undefined ? options.iconpos : el.jqmData( "iconpos" ), + theme: options.theme !== undefined ? options.theme : el.jqmData( "theme" ) || $.mobile.getInheritedTheme( el, "c" ), + inline: options.inline !== undefined ? options.inline : el.jqmData( "inline" ), + shadow: options.shadow !== undefined ? options.shadow : el.jqmData( "shadow" ), + corners: options.corners !== undefined ? options.corners : el.jqmData( "corners" ), + iconshadow: options.iconshadow !== undefined ? options.iconshadow : el.jqmData( "iconshadow" ), + mini: options.mini !== undefined ? options.mini : el.jqmData( "mini" ) + }, options ), + + // Classes Defined + innerClass = "ui-btn-inner", + textClass = "ui-btn-text", + buttonClass, iconClass, + // Button inner markup + buttonInner, + buttonText, + buttonIcon, + buttonElements; + + $.each( o, mapToDataAttr ); + + if ( el.jqmData( "rel" ) === "popup" && el.attr( "href" ) ) { + e.setAttribute( "aria-haspopup", true ); + e.setAttribute( "aria-owns", e.getAttribute( "href" ) ); + } + + // Check if this element is already enhanced + buttonElements = $.data( ( ( e.tagName === "INPUT" || e.tagName === "BUTTON" ) ? e.parentNode : e ), "buttonElements" ); + + if ( buttonElements ) { + e = buttonElements.outer; + el = $( e ); + buttonInner = buttonElements.inner; + buttonText = buttonElements.text; + // We will recreate this icon below + $( buttonElements.icon ).remove(); + buttonElements.icon = null; + } + else { + buttonInner = document.createElement( o.wrapperEls ); + buttonText = document.createElement( o.wrapperEls ); + } + buttonIcon = o.icon ? document.createElement( "span" ) : null; + + if ( attachEvents && !buttonElements ) { + attachEvents(); + } + + // if not, try to find closest theme container + if ( !o.theme ) { + o.theme = $.mobile.getInheritedTheme( el, "c" ); + } + + buttonClass = "ui-btn ui-btn-up-" + o.theme; + buttonClass += o.shadow ? " ui-shadow" : ""; + buttonClass += o.corners ? " ui-btn-corner-all" : ""; + + if ( o.mini !== undefined ) { + // Used to control styling in headers/footers, where buttons default to `mini` style. + buttonClass += o.mini === true ? " ui-mini" : " ui-fullsize"; + } + + if ( o.inline !== undefined ) { + // Used to control styling in headers/footers, where buttons default to `inline` style. + buttonClass += o.inline === true ? " ui-btn-inline" : " ui-btn-block"; + } + + if ( o.icon ) { + o.icon = "ui-icon-" + o.icon; + o.iconpos = o.iconpos || "left"; + + iconClass = "ui-icon " + o.icon; + + if ( o.iconshadow ) { + iconClass += " ui-icon-shadow"; + } + } + + if ( o.iconpos ) { + buttonClass += " ui-btn-icon-" + o.iconpos; + + if ( o.iconpos === "notext" && !el.attr( "title" ) ) { + el.attr( "title", el.getEncodedText() ); + } + } + + innerClass += o.corners ? " ui-btn-corner-all" : ""; + + if ( o.iconpos && o.iconpos === "notext" && !el.attr( "title" ) ) { + el.attr( "title", el.getEncodedText() ); + } + + if ( buttonElements ) { + el.removeClass( buttonElements.bcls || "" ); + } + el.removeClass( "ui-link" ).addClass( buttonClass ); + + buttonInner.className = innerClass; + + buttonText.className = textClass; + if ( !buttonElements ) { + buttonInner.appendChild( buttonText ); + } + if ( buttonIcon ) { + buttonIcon.className = iconClass; + if ( !( buttonElements && buttonElements.icon ) ) { + buttonIcon.innerHTML = " "; + buttonInner.appendChild( buttonIcon ); + } + } + + while ( e.firstChild && !buttonElements ) { + buttonText.appendChild( e.firstChild ); + } + + if ( !buttonElements ) { + e.appendChild( buttonInner ); + } + + // Assign a structure containing the elements of this button to the elements of this button. This + // will allow us to recognize this as an already-enhanced button in future calls to buttonMarkup(). + buttonElements = { + bcls : buttonClass, + outer : e, + inner : buttonInner, + text : buttonText, + icon : buttonIcon + }; + + $.data( e, 'buttonElements', buttonElements ); + $.data( buttonInner, 'buttonElements', buttonElements ); + $.data( buttonText, 'buttonElements', buttonElements ); + if ( buttonIcon ) { + $.data( buttonIcon, 'buttonElements', buttonElements ); + } + } + + return this; +}; + +$.fn.buttonMarkup.defaults = { + corners: true, + shadow: true, + iconshadow: true, + wrapperEls: "span" +}; + +function closestEnabledButton( element ) { + var cname; + + while ( element ) { + // Note that we check for typeof className below because the element we + // handed could be in an SVG DOM where className on SVG elements is defined to + // be of a different type (SVGAnimatedString). We only operate on HTML DOM + // elements, so we look for plain "string". + cname = ( typeof element.className === 'string' ) && ( element.className + ' ' ); + if ( cname && cname.indexOf( "ui-btn " ) > -1 && cname.indexOf( "ui-disabled " ) < 0 ) { + break; + } + + element = element.parentNode; + } + + return element; +} + +var attachEvents = function() { + var hoverDelay = $.mobile.buttonMarkup.hoverDelay, hov, foc; + + $( document ).bind( { + "vmousedown vmousecancel vmouseup vmouseover vmouseout focus blur scrollstart": function( event ) { + var theme, + $btn = $( closestEnabledButton( event.target ) ), + isTouchEvent = event.originalEvent && /^touch/.test( event.originalEvent.type ), + evt = event.type; + + if ( $btn.length ) { + theme = $btn.attr( "data-" + $.mobile.ns + "theme" ); + + if ( evt === "vmousedown" ) { + if ( isTouchEvent ) { + // Use a short delay to determine if the user is scrolling before highlighting + hov = setTimeout( function() { + $btn.removeClass( "ui-btn-up-" + theme ).addClass( "ui-btn-down-" + theme ); + }, hoverDelay ); + } else { + $btn.removeClass( "ui-btn-up-" + theme ).addClass( "ui-btn-down-" + theme ); + } + } else if ( evt === "vmousecancel" || evt === "vmouseup" ) { + $btn.removeClass( "ui-btn-down-" + theme ).addClass( "ui-btn-up-" + theme ); + } else if ( evt === "vmouseover" || evt === "focus" ) { + if ( isTouchEvent ) { + // Use a short delay to determine if the user is scrolling before highlighting + foc = setTimeout( function() { + $btn.removeClass( "ui-btn-up-" + theme ).addClass( "ui-btn-hover-" + theme ); + }, hoverDelay ); + } else { + $btn.removeClass( "ui-btn-up-" + theme ).addClass( "ui-btn-hover-" + theme ); + } + } else if ( evt === "vmouseout" || evt === "blur" || evt === "scrollstart" ) { + $btn.removeClass( "ui-btn-hover-" + theme + " ui-btn-down-" + theme ).addClass( "ui-btn-up-" + theme ); + if ( hov ) { + clearTimeout( hov ); + } + if ( foc ) { + clearTimeout( foc ); + } + } + } + }, + "focusin focus": function( event ) { + $( closestEnabledButton( event.target ) ).addClass( $.mobile.focusClass ); + }, + "focusout blur": function( event ) { + $( closestEnabledButton( event.target ) ).removeClass( $.mobile.focusClass ); + } + }); + + attachEvents = null; +}; + +//links in bars, or those with data-role become buttons +//auto self-init widgets +$( document ).bind( "pagecreate create", function( e ) { + + $( ":jqmData(role='button'), .ui-bar > a, .ui-header > a, .ui-footer > a, .ui-bar > :jqmData(role='controlgroup') > a", e.target ) + .jqmEnhanceable() + .not( "button, input, .ui-btn, :jqmData(role='none'), :jqmData(role='nojs')" ) + .buttonMarkup(); +}); + +})( jQuery ); + + +(function( $, undefined ) { + +$.widget( "mobile.collapsible", $.mobile.widget, { + options: { + expandCueText: " click to expand contents", + collapseCueText: " click to collapse contents", + collapsed: true, + heading: "h1,h2,h3,h4,h5,h6,legend", + theme: null, + contentTheme: null, + inset: true, + mini: false, + initSelector: ":jqmData(role='collapsible')" + }, + _create: function() { + + var $el = this.element, + o = this.options, + collapsible = $el.addClass( "ui-collapsible" ), + collapsibleHeading = $el.children( o.heading ).first(), + collapsedIcon = $el.jqmData( "collapsed-icon" ) || o.collapsedIcon, + expandedIcon = $el.jqmData( "expanded-icon" ) || o.expandedIcon, + collapsibleContent = collapsible.wrapInner( "
" ).children( ".ui-collapsible-content" ), + collapsibleSet = $el.closest( ":jqmData(role='collapsible-set')" ).addClass( "ui-collapsible-set" ); + + // Replace collapsibleHeading if it's a legend + if ( collapsibleHeading.is( "legend" ) ) { + collapsibleHeading = $( "
"+ collapsibleHeading.html() +"
" ).insertBefore( collapsibleHeading ); + collapsibleHeading.next().remove(); + } + + // If we are in a collapsible set + if ( collapsibleSet.length ) { + // Inherit the theme from collapsible-set + if ( !o.theme ) { + o.theme = collapsibleSet.jqmData( "theme" ) || $.mobile.getInheritedTheme( collapsibleSet, "c" ); + } + // Inherit the content-theme from collapsible-set + if ( !o.contentTheme ) { + o.contentTheme = collapsibleSet.jqmData( "content-theme" ); + } + + // Get the preference for collapsed icon in the set + if ( !o.collapsedIcon ) { + o.collapsedIcon = collapsibleSet.jqmData( "collapsed-icon" ); + } + // Get the preference for expanded icon in the set + if ( !o.expandedIcon ) { + o.expandedIcon = collapsibleSet.jqmData( "expanded-icon" ); + } + // Gets the preference icon position in the set + if ( !o.iconpos ) { + o.iconpos = collapsibleSet.jqmData( "iconpos" ); + } + // Inherit the preference for inset from collapsible-set or set the default value to ensure equalty within a set + if ( collapsibleSet.jqmData( "inset" ) !== undefined ) { + o.inset = collapsibleSet.jqmData( "inset" ); + } else { + o.inset = true; + } + // Gets the preference for mini in the set + if ( !o.mini ) { + o.mini = collapsibleSet.jqmData( "mini" ); + } + } else { + // get inherited theme if not a set and no theme has been set + if ( !o.theme ) { + o.theme = $.mobile.getInheritedTheme( $el, "c" ); + } + } + + if ( !!o.inset ) { + collapsible.addClass( "ui-collapsible-inset" ); + } + + collapsibleContent.addClass( ( o.contentTheme ) ? ( "ui-body-" + o.contentTheme ) : ""); + + collapsedIcon = $el.jqmData( "collapsed-icon" ) || o.collapsedIcon || "plus"; + expandedIcon = $el.jqmData( "expanded-icon" ) || o.expandedIcon || "minus"; + + collapsibleHeading + //drop heading in before content + .insertBefore( collapsibleContent ) + //modify markup & attributes + .addClass( "ui-collapsible-heading" ) + .append( "" ) + .wrapInner( "" ) + .find( "a" ) + .first() + .buttonMarkup({ + shadow: false, + corners: false, + iconpos: $el.jqmData( "iconpos" ) || o.iconpos || "left", + icon: collapsedIcon, + mini: o.mini, + theme: o.theme + }); + + if ( !!o.inset ) { + collapsibleHeading + .find( "a" ).first().add( ".ui-btn-inner", $el ) + .addClass( "ui-corner-top ui-corner-bottom" ); + } + + //events + collapsible + .bind( "expand collapse", function( event ) { + if ( !event.isDefaultPrevented() ) { + var $this = $( this ), + isCollapse = ( event.type === "collapse" ), + contentTheme = o.contentTheme; + + event.preventDefault(); + + collapsibleHeading + .toggleClass( "ui-collapsible-heading-collapsed", isCollapse ) + .find( ".ui-collapsible-heading-status" ) + .text( isCollapse ? o.expandCueText : o.collapseCueText ) + .end() + .find( ".ui-icon" ) + .toggleClass( "ui-icon-" + expandedIcon, !isCollapse ) + // logic or cause same icon for expanded/collapsed state would remove the ui-icon-class + .toggleClass( "ui-icon-" + collapsedIcon, ( isCollapse || expandedIcon === collapsedIcon ) ) + .end() + .find( "a" ).first().removeClass( $.mobile.activeBtnClass ); + + $this.toggleClass( "ui-collapsible-collapsed", isCollapse ); + collapsibleContent.toggleClass( "ui-collapsible-content-collapsed", isCollapse ).attr( "aria-hidden", isCollapse ); + + if ( contentTheme && !!o.inset && ( !collapsibleSet.length || collapsible.jqmData( "collapsible-last" ) ) ) { + collapsibleHeading + .find( "a" ).first().add( collapsibleHeading.find( ".ui-btn-inner" ) ) + .toggleClass( "ui-corner-bottom", isCollapse ); + collapsibleContent.toggleClass( "ui-corner-bottom", !isCollapse ); + } + collapsibleContent.trigger( "updatelayout" ); + } + }) + .trigger( o.collapsed ? "collapse" : "expand" ); + + collapsibleHeading + .bind( "tap", function( event ) { + collapsibleHeading.find( "a" ).first().addClass( $.mobile.activeBtnClass ); + }) + .bind( "click", function( event ) { + + var type = collapsibleHeading.is( ".ui-collapsible-heading-collapsed" ) ? "expand" : "collapse"; + + collapsible.trigger( type ); + + event.preventDefault(); + event.stopPropagation(); + }); + } +}); + +//auto self-init widgets +$( document ).bind( "pagecreate create", function( e ) { + $.mobile.collapsible.prototype.enhanceWithin( e.target ); +}); + +})( jQuery ); + +(function( $, undefined ) { + +$.widget( "mobile.collapsibleset", $.mobile.widget, { + options: { + initSelector: ":jqmData(role='collapsible-set')" + }, + _create: function() { + var $el = this.element.addClass( "ui-collapsible-set" ), + o = this.options; + + // Inherit the theme from collapsible-set + if ( !o.theme ) { + o.theme = $.mobile.getInheritedTheme( $el, "c" ); + } + // Inherit the content-theme from collapsible-set + if ( !o.contentTheme ) { + o.contentTheme = $el.jqmData( "content-theme" ); + } + + if ( $el.jqmData( "inset" ) !== undefined ) { + o.inset = $el.jqmData( "inset" ); + } + o.inset = o.inset !== undefined ? o.inset : true; + + // Initialize the collapsible set if it's not already initialized + if ( !$el.jqmData( "collapsiblebound" ) ) { + $el + .jqmData( "collapsiblebound", true ) + .bind( "expand collapse", function( event ) { + var isCollapse = ( event.type === "collapse" ), + collapsible = $( event.target ).closest( ".ui-collapsible" ), + widget = collapsible.data( "collapsible" ); + if ( collapsible.jqmData( "collapsible-last" ) && !!o.inset ) { + collapsible.find( ".ui-collapsible-heading" ).first() + .find( "a" ).first() + .toggleClass( "ui-corner-bottom", isCollapse ) + .find( ".ui-btn-inner" ) + .toggleClass( "ui-corner-bottom", isCollapse ); + collapsible.find( ".ui-collapsible-content" ).toggleClass( "ui-corner-bottom", !isCollapse ); + } + }) + .bind( "expand", function( event ) { + var closestCollapsible = $( event.target ) + .closest( ".ui-collapsible" ); + if ( closestCollapsible.parent().is( ":jqmData(role='collapsible-set')" ) ) { + closestCollapsible + .siblings( ".ui-collapsible" ) + .trigger( "collapse" ); + } + }); + } + }, + + _init: function() { + var $el = this.element, + collapsiblesInSet = $el.children( ":jqmData(role='collapsible')" ), + expanded = collapsiblesInSet.filter( ":jqmData(collapsed='false')" ); + this.refresh(); + + // Because the corners are handled by the collapsible itself and the default state is collapsed + // That was causing https://github.com/jquery/jquery-mobile/issues/4116 + expanded.trigger( "expand" ); + }, + + refresh: function() { + var $el = this.element, + o = this.options, + collapsiblesInSet = $el.children( ":jqmData(role='collapsible')" ); + + $.mobile.collapsible.prototype.enhance( collapsiblesInSet.not( ".ui-collapsible" ) ); + + // clean up borders + if ( !!o.inset ) { + collapsiblesInSet.each(function() { + $( this ).jqmRemoveData( "collapsible-last" ) + .find( ".ui-collapsible-heading" ) + .find( "a" ).first() + .removeClass( "ui-corner-top ui-corner-bottom" ) + .find( ".ui-btn-inner" ) + .removeClass( "ui-corner-top ui-corner-bottom" ); + }); + + collapsiblesInSet.first() + .find( "a" ) + .first() + .addClass( "ui-corner-top" ) + .find( ".ui-btn-inner" ) + .addClass( "ui-corner-top" ); + + collapsiblesInSet.last() + .jqmData( "collapsible-last", true ) + .find( "a" ) + .first() + .addClass( "ui-corner-bottom" ) + .find( ".ui-btn-inner" ) + .addClass( "ui-corner-bottom" ); + } + } +}); + +//auto self-init widgets +$( document ).bind( "pagecreate create", function( e ) { + $.mobile.collapsibleset.prototype.enhanceWithin( e.target ); +}); + +})( jQuery ); + +(function( $, undefined ) { + +$.widget( "mobile.navbar", $.mobile.widget, { + options: { + iconpos: "top", + grid: null, + initSelector: ":jqmData(role='navbar')" + }, + + _create: function() { + + var $navbar = this.element, + $navbtns = $navbar.find( "a" ), + iconpos = $navbtns.filter( ":jqmData(icon)" ).length ? + this.options.iconpos : undefined; + + $navbar.addClass( "ui-navbar ui-mini" ) + .attr( "role", "navigation" ) + .find( "ul" ) + .jqmEnhanceable() + .grid({ grid: this.options.grid }); + + $navbtns.buttonMarkup({ + corners: false, + shadow: false, + inline: true, + iconpos: iconpos + }); + + $navbar.delegate( "a", "vclick", function( event ) { + if ( !$(event.target).hasClass( "ui-disabled" ) ) { + $navbtns.removeClass( $.mobile.activeBtnClass ); + $( this ).addClass( $.mobile.activeBtnClass ); + } + }); + + // Buttons in the navbar with ui-state-persist class should regain their active state before page show + $navbar.closest( ".ui-page" ).bind( "pagebeforeshow", function() { + $navbtns.filter( ".ui-state-persist" ).addClass( $.mobile.activeBtnClass ); + }); + } +}); + +//auto self-init widgets +$( document ).bind( "pagecreate create", function( e ) { + $.mobile.navbar.prototype.enhanceWithin( e.target ); +}); + +})( jQuery ); + +(function( $, undefined ) { + +//Keeps track of the number of lists per page UID +//This allows support for multiple nested list in the same page +//https://github.com/jquery/jquery-mobile/issues/1617 +var listCountPerPage = {}; + +$.widget( "mobile.listview", $.mobile.widget, { + + options: { + theme: null, + countTheme: "c", + headerTheme: "b", + dividerTheme: "b", + icon: "arrow-r", + splitIcon: "arrow-r", + splitTheme: "b", + inset: false, + initSelector: ":jqmData(role='listview')" + }, + + _create: function() { + var t = this, + listviewClasses = ""; + + listviewClasses += t.options.inset ? " ui-listview-inset ui-corner-all ui-shadow " : ""; + + // create listview markup + t.element.addClass(function( i, orig ) { + return orig + " ui-listview " + listviewClasses; + }); + + t.refresh( true ); + }, + + _removeCorners: function( li, which ) { + var top = "ui-corner-top ui-corner-tr ui-corner-tl", + bot = "ui-corner-bottom ui-corner-br ui-corner-bl"; + + li = li.add( li.find( ".ui-btn-inner, .ui-li-link-alt, .ui-li-thumb" ) ); + + if ( which === "top" ) { + li.removeClass( top ); + } else if ( which === "bottom" ) { + li.removeClass( bot ); + } else { + li.removeClass( top + " " + bot ); + } + }, + + _refreshCorners: function( create ) { + var $li, + $visibleli, + $topli, + $bottomli; + + $li = this.element.children( "li" ); + // At create time and when autodividers calls refresh the li are not visible yet so we need to rely on .ui-screen-hidden + $visibleli = create || $li.filter( ":visible" ).length === 0 ? $li.not( ".ui-screen-hidden" ) : $li.filter( ":visible" ); + + // ui-li-last is used for setting border-bottom on the last li + $li.filter( ".ui-li-last" ).removeClass( "ui-li-last" ); + + if ( this.options.inset ) { + this._removeCorners( $li ); + + // Select the first visible li element + $topli = $visibleli.first() + .addClass( "ui-corner-top" ); + + $topli.add( $topli.find( ".ui-btn-inner" ) + .not( ".ui-li-link-alt span:first-child" ) ) + .addClass( "ui-corner-top" ) + .end() + .find( ".ui-li-link-alt, .ui-li-link-alt span:first-child" ) + .addClass( "ui-corner-tr" ) + .end() + .find( ".ui-li-thumb" ) + .not( ".ui-li-icon" ) + .addClass( "ui-corner-tl" ); + + // Select the last visible li element + $bottomli = $visibleli.last() + .addClass( "ui-corner-bottom ui-li-last" ); + + $bottomli.add( $bottomli.find( ".ui-btn-inner" ) ) + .find( ".ui-li-link-alt" ) + .addClass( "ui-corner-br" ) + .end() + .find( ".ui-li-thumb" ) + .not( ".ui-li-icon" ) + .addClass( "ui-corner-bl" ); + } else { + $visibleli.last().addClass( "ui-li-last" ); + } + if ( !create ) { + this.element.trigger( "updatelayout" ); + } + }, + + // This is a generic utility method for finding the first + // node with a given nodeName. It uses basic DOM traversal + // to be fast and is meant to be a substitute for simple + // $.fn.closest() and $.fn.children() calls on a single + // element. Note that callers must pass both the lowerCase + // and upperCase version of the nodeName they are looking for. + // The main reason for this is that this function will be + // called many times and we want to avoid having to lowercase + // the nodeName from the element every time to ensure we have + // a match. Note that this function lives here for now, but may + // be moved into $.mobile if other components need a similar method. + _findFirstElementByTagName: function( ele, nextProp, lcName, ucName ) { + var dict = {}; + dict[ lcName ] = dict[ ucName ] = true; + while ( ele ) { + if ( dict[ ele.nodeName ] ) { + return ele; + } + ele = ele[ nextProp ]; + } + return null; + }, + _getChildrenByTagName: function( ele, lcName, ucName ) { + var results = [], + dict = {}; + dict[ lcName ] = dict[ ucName ] = true; + ele = ele.firstChild; + while ( ele ) { + if ( dict[ ele.nodeName ] ) { + results.push( ele ); + } + ele = ele.nextSibling; + } + return $( results ); + }, + + _addThumbClasses: function( containers ) { + var i, img, len = containers.length; + for ( i = 0; i < len; i++ ) { + img = $( this._findFirstElementByTagName( containers[ i ].firstChild, "nextSibling", "img", "IMG" ) ); + if ( img.length ) { + img.addClass( "ui-li-thumb" ); + $( this._findFirstElementByTagName( img[ 0 ].parentNode, "parentNode", "li", "LI" ) ).addClass( img.is( ".ui-li-icon" ) ? "ui-li-has-icon" : "ui-li-has-thumb" ); + } + } + }, + + refresh: function( create ) { + this.parentPage = this.element.closest( ".ui-page" ); + this._createSubPages(); + + var o = this.options, + $list = this.element, + self = this, + dividertheme = $list.jqmData( "dividertheme" ) || o.dividerTheme, + listsplittheme = $list.jqmData( "splittheme" ), + listspliticon = $list.jqmData( "spliticon" ), + listicon = $list.jqmData( "icon" ), + li = this._getChildrenByTagName( $list[ 0 ], "li", "LI" ), + ol = !!$.nodeName( $list[ 0 ], "ol" ), + jsCount = !$.support.cssPseudoElement, + start = $list.attr( "start" ), + itemClassDict = {}, + item, itemClass, itemTheme, + a, last, splittheme, counter, startCount, newStartCount, countParent, icon, imgParents, img, linkIcon; + + if ( ol && jsCount ) { + $list.find( ".ui-li-dec" ).remove(); + } + + if ( ol ) { + // Check if a start attribute has been set while taking a value of 0 into account + if ( start || start === 0 ) { + if ( !jsCount ) { + startCount = parseFloat( start ) - 1; + $list.css( "counter-reset", "listnumbering " + startCount ); + } else { + counter = parseFloat( start ); + } + } else if ( jsCount ) { + counter = 1; + } + } + + if ( !o.theme ) { + o.theme = $.mobile.getInheritedTheme( this.element, "c" ); + } + + for ( var pos = 0, numli = li.length; pos < numli; pos++ ) { + item = li.eq( pos ); + itemClass = "ui-li"; + + // If we're creating the element, we update it regardless + if ( create || !item.hasClass( "ui-li" ) ) { + itemTheme = item.jqmData( "theme" ) || o.theme; + a = this._getChildrenByTagName( item[ 0 ], "a", "A" ); + var isDivider = ( item.jqmData( "role" ) === "list-divider" ); + + if ( a.length && !isDivider ) { + icon = item.jqmData( "icon" ); + + item.buttonMarkup({ + wrapperEls: "div", + shadow: false, + corners: false, + iconpos: "right", + icon: a.length > 1 || icon === false ? false : icon || listicon || o.icon, + theme: itemTheme + }); + + if ( ( icon !== false ) && ( a.length === 1 ) ) { + item.addClass( "ui-li-has-arrow" ); + } + + a.first().removeClass( "ui-link" ).addClass( "ui-link-inherit" ); + + if ( a.length > 1 ) { + itemClass += " ui-li-has-alt"; + + last = a.last(); + splittheme = listsplittheme || last.jqmData( "theme" ) || o.splitTheme; + linkIcon = last.jqmData( "icon" ); + + last.appendTo( item ) + .attr( "title", last.getEncodedText() ) + .addClass( "ui-li-link-alt" ) + .empty() + .buttonMarkup({ + shadow: false, + corners: false, + theme: itemTheme, + icon: false, + iconpos: "notext" + }) + .find( ".ui-btn-inner" ) + .append( + $( document.createElement( "span" ) ).buttonMarkup({ + shadow: true, + corners: true, + theme: splittheme, + iconpos: "notext", + // link icon overrides list item icon overrides ul element overrides options + icon: linkIcon || icon || listspliticon || o.splitIcon + }) + ); + } + } else if ( isDivider ) { + + itemClass += " ui-li-divider ui-bar-" + dividertheme; + item.attr( "role", "heading" ); + + if ( ol ) { + //reset counter when a divider heading is encountered + if ( start || start === 0 ) { + if ( !jsCount ) { + newStartCount = parseFloat( start ) - 1; + item.css( "counter-reset", "listnumbering " + newStartCount ); + } else { + counter = parseFloat( start ); + } + } else if ( jsCount ) { + counter = 1; + } + } + + } else { + itemClass += " ui-li-static ui-btn-up-" + itemTheme; + } + } + + if ( ol && jsCount && itemClass.indexOf( "ui-li-divider" ) < 0 ) { + countParent = itemClass.indexOf( "ui-li-static" ) > 0 ? item : item.find( ".ui-link-inherit" ); + + countParent.addClass( "ui-li-jsnumbering" ) + .prepend( "" + ( counter++ ) + ". " ); + } + + // Instead of setting item class directly on the list item and its + // btn-inner at this point in time, push the item into a dictionary + // that tells us what class to set on it so we can do this after this + // processing loop is finished. + + if ( !itemClassDict[ itemClass ] ) { + itemClassDict[ itemClass ] = []; + } + + itemClassDict[ itemClass ].push( item[ 0 ] ); + } + + // Set the appropriate listview item classes on each list item + // and their btn-inner elements. The main reason we didn't do this + // in the for-loop above is because we can eliminate per-item function overhead + // by calling addClass() and children() once or twice afterwards. This + // can give us a significant boost on platforms like WP7.5. + + for ( itemClass in itemClassDict ) { + $( itemClassDict[ itemClass ] ).addClass( itemClass ).children( ".ui-btn-inner" ).addClass( itemClass ); + } + + $list.find( "h1, h2, h3, h4, h5, h6" ).addClass( "ui-li-heading" ) + .end() + + .find( "p, dl" ).addClass( "ui-li-desc" ) + .end() + + .find( ".ui-li-aside" ).each(function() { + var $this = $( this ); + $this.prependTo( $this.parent() ); //shift aside to front for css float + }) + .end() + + .find( ".ui-li-count" ).each(function() { + $( this ).closest( "li" ).addClass( "ui-li-has-count" ); + }).addClass( "ui-btn-up-" + ( $list.jqmData( "counttheme" ) || this.options.countTheme) + " ui-btn-corner-all" ); + + // The idea here is to look at the first image in the list item + // itself, and any .ui-link-inherit element it may contain, so we + // can place the appropriate classes on the image and list item. + // Note that we used to use something like: + // + // li.find(">img:eq(0), .ui-link-inherit>img:eq(0)").each( ... ); + // + // But executing a find() like that on Windows Phone 7.5 took a + // really long time. Walking things manually with the code below + // allows the 400 listview item page to load in about 3 seconds as + // opposed to 30 seconds. + + this._addThumbClasses( li ); + this._addThumbClasses( $list.find( ".ui-link-inherit" ) ); + + this._refreshCorners( create ); + + // autodividers binds to this to redraw dividers after the listview refresh + this._trigger( "afterrefresh" ); + }, + + //create a string for ID/subpage url creation + _idStringEscape: function( str ) { + return str.replace(/[^a-zA-Z0-9]/g, '-'); + }, + + _createSubPages: function() { + var parentList = this.element, + parentPage = parentList.closest( ".ui-page" ), + parentUrl = parentPage.jqmData( "url" ), + parentId = parentUrl || parentPage[ 0 ][ $.expando ], + parentListId = parentList.attr( "id" ), + o = this.options, + dns = "data-" + $.mobile.ns, + self = this, + persistentFooterID = parentPage.find( ":jqmData(role='footer')" ).jqmData( "id" ), + hasSubPages; + + if ( typeof listCountPerPage[ parentId ] === "undefined" ) { + listCountPerPage[ parentId ] = -1; + } + + parentListId = parentListId || ++listCountPerPage[ parentId ]; + + $( parentList.find( "li>ul, li>ol" ).toArray().reverse() ).each(function( i ) { + var self = this, + list = $( this ), + listId = list.attr( "id" ) || parentListId + "-" + i, + parent = list.parent(), + nodeElsFull = $( list.prevAll().toArray().reverse() ), + nodeEls = nodeElsFull.length ? nodeElsFull : $( "" + $.trim(parent.contents()[ 0 ].nodeValue) + "" ), + title = nodeEls.first().getEncodedText(),//url limits to first 30 chars of text + id = ( parentUrl || "" ) + "&" + $.mobile.subPageUrlKey + "=" + listId, + theme = list.jqmData( "theme" ) || o.theme, + countTheme = list.jqmData( "counttheme" ) || parentList.jqmData( "counttheme" ) || o.countTheme, + newPage, anchor; + + //define hasSubPages for use in later removal + hasSubPages = true; + + newPage = list.detach() + .wrap( "
" ) + .parent() + .before( "
" + title + "
" ) + .after( persistentFooterID ? $( "
" ) : "" ) + .parent() + .appendTo( $.mobile.pageContainer ); + + newPage.page(); + + anchor = parent.find( 'a:first' ); + + if ( !anchor.length ) { + anchor = $( "" ).html( nodeEls || title ).prependTo( parent.empty() ); + } + + anchor.attr( "href", "#" + id ); + + }).listview(); + + // on pagehide, remove any nested pages along with the parent page, as long as they aren't active + // and aren't embedded + if ( hasSubPages && + parentPage.is( ":jqmData(external-page='true')" ) && + parentPage.data( "page" ).options.domCache === false ) { + + var newRemove = function( e, ui ) { + var nextPage = ui.nextPage, npURL, + prEvent = new $.Event( "pageremove" ); + + if ( ui.nextPage ) { + npURL = nextPage.jqmData( "url" ); + if ( npURL.indexOf( parentUrl + "&" + $.mobile.subPageUrlKey ) !== 0 ) { + self.childPages().remove(); + parentPage.trigger( prEvent ); + if ( !prEvent.isDefaultPrevented() ) { + parentPage.removeWithDependents(); + } + } + } + }; + + // unbind the original page remove and replace with our specialized version + parentPage + .unbind( "pagehide.remove" ) + .bind( "pagehide.remove", newRemove); + } + }, + + // TODO sort out a better way to track sub pages of the listview this is brittle + childPages: function() { + var parentUrl = this.parentPage.jqmData( "url" ); + + return $( ":jqmData(url^='"+ parentUrl + "&" + $.mobile.subPageUrlKey + "')" ); + } +}); + +//auto self-init widgets +$( document ).bind( "pagecreate create", function( e ) { + $.mobile.listview.prototype.enhanceWithin( e.target ); +}); + +})( jQuery ); + +(function( $, undefined ) { + +$.mobile.listview.prototype.options.autodividers = false; +$.mobile.listview.prototype.options.autodividersSelector = function( elt ) { + // look for the text in the given element + var text = $.trim( elt.text() ) || null; + + if ( !text ) { + return null; + } + + // create the text for the divider (first uppercased letter) + text = text.slice( 0, 1 ).toUpperCase(); + + return text; +}; + +$( document ).delegate( "ul,ol", "listviewcreate", function() { + + var list = $( this ), + listview = list.data( "listview" ); + + if ( !listview || !listview.options.autodividers ) { + return; + } + + var replaceDividers = function () { + list.find( "li:jqmData(role='list-divider')" ).remove(); + + var lis = list.find( 'li' ), + lastDividerText = null, li, dividerText; + + for ( var i = 0; i < lis.length ; i++ ) { + li = lis[i]; + dividerText = listview.options.autodividersSelector( $( li ) ); + + if ( dividerText && lastDividerText !== dividerText ) { + var divider = document.createElement( 'li' ); + divider.appendChild( document.createTextNode( dividerText ) ); + divider.setAttribute( 'data-' + $.mobile.ns + 'role', 'list-divider' ); + li.parentNode.insertBefore( divider, li ); + } + + lastDividerText = dividerText; + } + }; + + var afterListviewRefresh = function () { + list.unbind( 'listviewafterrefresh', afterListviewRefresh ); + replaceDividers(); + listview.refresh(); + list.bind( 'listviewafterrefresh', afterListviewRefresh ); + }; + + afterListviewRefresh(); +}); + +})( jQuery ); + +/* +* "checkboxradio" plugin +*/ + +(function( $, undefined ) { + +$.widget( "mobile.checkboxradio", $.mobile.widget, { + options: { + theme: null, + mini: false, + initSelector: "input[type='checkbox'],input[type='radio']" + }, + _create: function() { + var self = this, + input = this.element, + o = this.options, + inheritAttr = function( input, dataAttr ) { + return input.jqmData( dataAttr ) || input.closest( "form, fieldset" ).jqmData( dataAttr ); + }, + // NOTE: Windows Phone could not find the label through a selector + // filter works though. + parentLabel = $( input ).closest( "label" ), + label = parentLabel.length ? parentLabel : $( input ).closest( "form, fieldset, :jqmData(role='page'), :jqmData(role='dialog')" ).find( "label" ).filter( "[for='" + input[0].id + "']" ).first(), + inputtype = input[0].type, + mini = inheritAttr( input, "mini" ) || o.mini, + checkedState = inputtype + "-on", + uncheckedState = inputtype + "-off", + icon = input.parents( ":jqmData(type='horizontal')" ).length ? undefined : uncheckedState, + iconpos = inheritAttr( input, "iconpos" ), + activeBtn = icon ? "" : " " + $.mobile.activeBtnClass, + checkedClass = "ui-" + checkedState + activeBtn, + uncheckedClass = "ui-" + uncheckedState, + checkedicon = "ui-icon-" + checkedState, + uncheckedicon = "ui-icon-" + uncheckedState; + + if ( inputtype !== "checkbox" && inputtype !== "radio" ) { + return; + } + + // Expose for other methods + $.extend( this, { + label: label, + inputtype: inputtype, + checkedClass: checkedClass, + uncheckedClass: uncheckedClass, + checkedicon: checkedicon, + uncheckedicon: uncheckedicon + }); + + // If there's no selected theme check the data attr + if ( !o.theme ) { + o.theme = $.mobile.getInheritedTheme( this.element, "c" ); + } + + label.buttonMarkup({ + theme: o.theme, + icon: icon, + shadow: false, + mini: mini, + iconpos: iconpos + }); + + // Wrap the input + label in a div + var wrapper = document.createElement('div'); + wrapper.className = 'ui-' + inputtype; + + input.add( label ).wrapAll( wrapper ); + + label.bind({ + vmouseover: function( event ) { + if ( $( this ).parent().is( ".ui-disabled" ) ) { + event.stopPropagation(); + } + }, + + vclick: function( event ) { + if ( input.is( ":disabled" ) ) { + event.preventDefault(); + return; + } + + self._cacheVals(); + + input.prop( "checked", inputtype === "radio" && true || !input.prop( "checked" ) ); + + // trigger click handler's bound directly to the input as a substitute for + // how label clicks behave normally in the browsers + // TODO: it would be nice to let the browser's handle the clicks and pass them + // through to the associate input. we can swallow that click at the parent + // wrapper element level + input.triggerHandler( 'click' ); + + // Input set for common radio buttons will contain all the radio + // buttons, but will not for checkboxes. clearing the checked status + // of other radios ensures the active button state is applied properly + self._getInputSet().not( input ).prop( "checked", false ); + + self._updateAll(); + return false; + } + }); + + input + .bind({ + vmousedown: function() { + self._cacheVals(); + }, + + vclick: function() { + var $this = $( this ); + + // Adds checked attribute to checked input when keyboard is used + if ( $this.is( ":checked" ) ) { + + $this.prop( "checked", true); + self._getInputSet().not( $this ).prop( "checked", false ); + } else { + + $this.prop( "checked", false ); + } + + self._updateAll(); + }, + + focus: function() { + label.addClass( $.mobile.focusClass ); + }, + + blur: function() { + label.removeClass( $.mobile.focusClass ); + } + }); + + if ( this._handleFormReset ) { + this._handleFormReset(); + } + this.refresh(); + }, + + _cacheVals: function() { + this._getInputSet().each(function() { + $( this ).jqmData( "cacheVal", this.checked ); + }); + }, + + //returns either a set of radios with the same name attribute, or a single checkbox + _getInputSet: function() { + if ( this.inputtype === "checkbox" ) { + return this.element; + } + + return this.element.closest( "form, fieldset, :jqmData(role='page'), :jqmData(role='dialog')" ) + .find( "input[name='" + this.element[0].name + "'][type='" + this.inputtype + "']" ); + }, + + _updateAll: function() { + var self = this; + + this._getInputSet().each(function() { + var $this = $( this ); + + if ( this.checked || self.inputtype === "checkbox" ) { + $this.trigger( "change" ); + } + }) + .checkboxradio( "refresh" ); + }, + + _reset: function() { + this.refresh(); + }, + + refresh: function() { + var input = this.element[0], + label = this.label, + icon = label.find( ".ui-icon" ); + + if ( input.checked ) { + label.addClass( this.checkedClass ).removeClass( this.uncheckedClass ); + icon.addClass( this.checkedicon ).removeClass( this.uncheckedicon ); + } else { + label.removeClass( this.checkedClass ).addClass( this.uncheckedClass ); + icon.removeClass( this.checkedicon ).addClass( this.uncheckedicon ); + } + + if ( input.disabled ) { + this.disable(); + } else { + this.enable(); + } + }, + + disable: function() { + this.element.prop( "disabled", true ).parent().addClass( "ui-disabled" ); + }, + + enable: function() { + this.element.prop( "disabled", false ).parent().removeClass( "ui-disabled" ); + } +}); + +$.widget( "mobile.checkboxradio", $.mobile.checkboxradio, $.mobile.behaviors.formReset ); + +//auto self-init widgets +$( document ).bind( "pagecreate create", function( e ) { + $.mobile.checkboxradio.prototype.enhanceWithin( e.target, true ); +}); + +})( jQuery ); + +(function( $, undefined ) { + +$.widget( "mobile.button", $.mobile.widget, { + options: { + theme: null, + icon: null, + iconpos: null, + corners: true, + shadow: true, + iconshadow: true, + initSelector: "button, [type='button'], [type='submit'], [type='reset']" + }, + _create: function() { + var $el = this.element, + $button, + o = this.options, + type, + name, + inline = o.inline || $el.jqmData( "inline" ), + mini = o.mini || $el.jqmData( "mini" ), + classes = "", + $buttonPlaceholder; + + // if this is a link, check if it's been enhanced and, if not, use the right function + if ( $el[ 0 ].tagName === "A" ) { + if ( !$el.hasClass( "ui-btn" ) ) { + $el.buttonMarkup(); + } + + return; + } + + // get the inherited theme + // TODO centralize for all widgets + if ( !this.options.theme ) { + this.options.theme = $.mobile.getInheritedTheme( this.element, "c" ); + } + + // TODO: Post 1.1--once we have time to test thoroughly--any classes manually applied to the original element should be carried over to the enhanced element, with an `-enhanced` suffix. See https://github.com/jquery/jquery-mobile/issues/3577 + /* if ( $el[0].className.length ) { + classes = $el[0].className; + } */ + if ( !!~$el[0].className.indexOf( "ui-btn-left" ) ) { + classes = "ui-btn-left"; + } + + if ( !!~$el[0].className.indexOf( "ui-btn-right" ) ) { + classes = "ui-btn-right"; + } + + if ( $el.attr( "type" ) === "submit" || $el.attr( "type" ) === "reset" ) { + classes ? classes += " ui-submit" : classes = "ui-submit"; + } + $( "label[for='" + $el.attr( "id" ) + "']" ).addClass( "ui-submit" ); + + // Add ARIA role + this.button = $( "
" ) + [ $el.html() ? "html" : "text" ]( $el.html() || $el.val() ) + .insertBefore( $el ) + .buttonMarkup({ + theme: o.theme, + icon: o.icon, + iconpos: o.iconpos, + inline: inline, + corners: o.corners, + shadow: o.shadow, + iconshadow: o.iconshadow, + mini: mini + }) + .addClass( classes ) + .append( $el.addClass( "ui-btn-hidden" ) ); + + $button = this.button; + type = $el.attr( "type" ); + name = $el.attr( "name" ); + + // Add hidden input during submit if input type="submit" has a name. + if ( type !== "button" && type !== "reset" && name ) { + $el.bind( "vclick", function() { + // Add hidden input if it doesn't already exist. + if ( $buttonPlaceholder === undefined ) { + $buttonPlaceholder = $( "", { + type: "hidden", + name: $el.attr( "name" ), + value: $el.attr( "value" ) + }).insertBefore( $el ); + + // Bind to doc to remove after submit handling + $( document ).one( "submit", function() { + $buttonPlaceholder.remove(); + + // reset the local var so that the hidden input + // will be re-added on subsequent clicks + $buttonPlaceholder = undefined; + }); + } + }); + } + + $el.bind({ + focus: function() { + $button.addClass( $.mobile.focusClass ); + }, + + blur: function() { + $button.removeClass( $.mobile.focusClass ); + } + }); + + this.refresh(); + }, + + enable: function() { + this.element.attr( "disabled", false ); + this.button.removeClass( "ui-disabled" ).attr( "aria-disabled", false ); + return this._setOption( "disabled", false ); + }, + + disable: function() { + this.element.attr( "disabled", true ); + this.button.addClass( "ui-disabled" ).attr( "aria-disabled", true ); + return this._setOption( "disabled", true ); + }, + + refresh: function() { + var $el = this.element; + + if ( $el.prop("disabled") ) { + this.disable(); + } else { + this.enable(); + } + + // Grab the button's text element from its implementation-independent data item + $( this.button.data( 'buttonElements' ).text )[ $el.html() ? "html" : "text" ]( $el.html() || $el.val() ); + } +}); + +//auto self-init widgets +$( document ).bind( "pagecreate create", function( e ) { + $.mobile.button.prototype.enhanceWithin( e.target, true ); +}); + +})( jQuery ); + +(function( $, undefined ) { + +$.fn.controlgroup = function( options ) { + function flipClasses( els, flCorners ) { + els.removeClass( "ui-btn-corner-all ui-corner-top ui-corner-bottom ui-corner-left ui-corner-right ui-controlgroup-last ui-shadow" ) + .eq( 0 ).addClass( flCorners[ 0 ] ) + .end() + .last().addClass( flCorners[ 1 ] ).addClass( "ui-controlgroup-last" ); + } + + return this.each(function() { + var $el = $( this ), + o = $.extend({ + direction: $el.jqmData( "type" ) || "vertical", + shadow: false, + excludeInvisible: true, + mini: $el.jqmData( "mini" ) + }, options ), + grouplegend = $el.children( "legend" ), + groupheading = $el.children( ".ui-controlgroup-label" ), + groupcontrols = $el.children( ".ui-controlgroup-controls" ), + flCorners = o.direction === "horizontal" ? [ "ui-corner-left", "ui-corner-right" ] : [ "ui-corner-top", "ui-corner-bottom" ], + type = $el.find( "input" ).first().attr( "type" ); + + // First unwrap the controls if the controlgroup was already enhanced + if ( groupcontrols.length ) { + groupcontrols.contents().unwrap(); + } + $el.wrapInner( "
" ); + + if ( grouplegend.length ) { + // Replace legend with more stylable replacement div + $( "
" + grouplegend.html() + "
" ).insertBefore( $el.children( 0 ) ); + grouplegend.remove(); + } else if ( groupheading.length ) { + // Just move the heading if the controlgroup was already enhanced + $el.prepend( groupheading ); + } + + $el.addClass( "ui-corner-all ui-controlgroup ui-controlgroup-" + o.direction ); + + flipClasses( $el.find( ".ui-btn" + ( o.excludeInvisible ? ":visible" : "" ) ).not( '.ui-slider-handle' ), flCorners ); + flipClasses( $el.find( ".ui-btn-inner" ), flCorners ); + + if ( o.shadow ) { + $el.addClass( "ui-shadow" ); + } + + if ( o.mini ) { + $el.addClass( "ui-mini" ); + } + + }); +}; + +// The pagecreate handler for controlgroup is in jquery.mobile.init because of the soft-dependency on the wrapped widgets + +})(jQuery); + +(function( $, undefined ) { + +$( document ).bind( "pagecreate create", function( e ) { + + //links within content areas, tests included with page + $( e.target ) + .find( "a" ) + .jqmEnhanceable() + .not( ".ui-btn, .ui-link-inherit, :jqmData(role='none'), :jqmData(role='nojs')" ) + .addClass( "ui-link" ); + +}); + +})( jQuery ); + + +(function( $, undefined ) { + + function fitSegmentInsideSegment( winSize, segSize, offset, desired ) { + var ret = desired; + + if ( winSize < segSize ) { + // Center segment if it's bigger than the window + ret = offset + ( winSize - segSize ) / 2; + } else { + // Otherwise center it at the desired coordinate while keeping it completely inside the window + ret = Math.min( Math.max( offset, desired - segSize / 2 ), offset + winSize - segSize ); + } + + return ret; + } + + function windowCoords() { + var $win = $( window ); + + return { + x: $win.scrollLeft(), + y: $win.scrollTop(), + cx: ( window.innerWidth || $win.width() ), + cy: ( window.innerHeight || $win.height() ) + }; + } + + $.widget( "mobile.popup", $.mobile.widget, { + options: { + theme: null, + overlayTheme: null, + shadow: true, + corners: true, + transition: "none", + positionTo: "origin", + tolerance: null, + initSelector: ":jqmData(role='popup')", + closeLinkSelector: "a:jqmData(rel='back')", + closeLinkEvents: "click.popup", + navigateEvents: "navigate.popup", + closeEvents: "navigate.popup pagebeforechange.popup", + + // NOTE Windows Phone 7 has a scroll position caching issue that + // requires us to disable popup history management by default + // https://github.com/jquery/jquery-mobile/issues/4784 + // + // NOTE this option is modified in _create! + history: !$.mobile.browser.ie + }, + + _eatEventAndClose: function( e ) { + e.preventDefault(); + e.stopImmediatePropagation(); + this.close(); + return false; + }, + + // Make sure the screen size is increased beyond the page height if the popup's causes the document to increase in height + _resizeScreen: function() { + var popupHeight = this._ui.container.outerHeight( true ); + + this._ui.screen.removeAttr( "style" ); + if ( popupHeight > this._ui.screen.height() ) { + this._ui.screen.height( popupHeight ); + } + }, + + _handleWindowKeyUp: function( e ) { + if ( this._isOpen && e.keyCode === $.mobile.keyCode.ESCAPE ) { + return this._eatEventAndClose( e ); + } + }, + + _expectResizeEvent: function() { + var winCoords = windowCoords(); + + if ( this._resizeData ) { + if ( winCoords.x === this._resizeData.winCoords.x && + winCoords.y === this._resizeData.winCoords.y && + winCoords.cx === this._resizeData.winCoords.cx && + winCoords.cy === this._resizeData.winCoords.cy ) { + // timeout not refreshed + return false; + } else { + // clear existing timeout - it will be refreshed below + clearTimeout( this._resizeData.timeoutId ); + } + } + + this._resizeData = { + timeoutId: setTimeout( $.proxy( this, "_resizeTimeout" ), 200 ), + winCoords: winCoords + }; + + return true; + }, + + _resizeTimeout: function() { + if ( this._isOpen ) { + if ( !this._expectResizeEvent() ) { + if ( this._ui.container.hasClass( "ui-popup-hidden" ) ) { + // effectively rapid-open the popup while leaving the screen intact + this._trigger( "beforeposition" ); + this._ui.container + .removeClass( "ui-popup-hidden" ) + .offset( this._placementCoords( this._desiredCoords( undefined, undefined, "window" ) ) ); + } + + this._resizeScreen(); + this._resizeData = null; + this._orientationchangeInProgress = false; + } + } else { + this._resizeData = null; + this._orientationchangeInProgress = false; + } + }, + + _handleWindowResize: function( e ) { + if ( this._isOpen ) { + if ( ( this._expectResizeEvent() || this._orientationchangeInProgress ) && + !this._ui.container.hasClass( "ui-popup-hidden" ) ) { + // effectively rapid-close the popup while leaving the screen intact + this._ui.container + .addClass( "ui-popup-hidden" ) + .removeAttr( "style" ); + } + } + }, + + _handleWindowOrientationchange: function( e ) { + if ( !this._orientationchangeInProgress && this._isOpen ) { + this._expectResizeEvent(); + this._orientationchangeInProgress = true; + } + }, + + _create: function() { + var ui = { + screen: $( "
" ), + placeholder: $( "
" ), + container: $( "
" ) + }, + thisPage = this.element.closest( ".ui-page" ), + myId = this.element.attr( "id" ), + self = this; + + // We need to adjust the history option to be false if there's no AJAX nav. + // We can't do it in the option declarations because those are run before + // it is determined whether there shall be AJAX nav. + this.options.history = this.options.history && $.mobile.ajaxEnabled && $.mobile.hashListeningEnabled; + + if ( thisPage.length === 0 ) { + thisPage = $( "body" ); + } + + // define the container for navigation event bindings + // TODO this would be nice at the the mobile widget level + this.options.container = this.options.container || $.mobile.pageContainer; + + // Apply the proto + thisPage.append( ui.screen ); + ui.container.insertAfter( ui.screen ); + // Leave a placeholder where the element used to be + ui.placeholder.insertAfter( this.element ); + if ( myId ) { + ui.screen.attr( "id", myId + "-screen" ); + ui.container.attr( "id", myId + "-popup" ); + ui.placeholder.html( "" ); + } + ui.container.append( this.element ); + + // Add class to popup element + this.element.addClass( "ui-popup" ); + + // Define instance variables + $.extend( this, { + _scrollTop: 0, + _page: thisPage, + _ui: ui, + _fallbackTransition: "", + _currentTransition: false, + _prereqs: null, + _isOpen: false, + _tolerance: null, + _resizeData: null, + _orientationchangeInProgress: false, + _globalHandlers: [ + { + src: $( window ), + handler: { + orientationchange: $.proxy( this, "_handleWindowOrientationchange" ), + resize: $.proxy( this, "_handleWindowResize" ), + keyup: $.proxy( this, "_handleWindowKeyUp" ) + } + } + ] + }); + + $.each( this.options, function( key, value ) { + // Cause initial options to be applied by their handler by temporarily setting the option to undefined + // - the handler then sets it to the initial value + self.options[ key ] = undefined; + self._setOption( key, value, true ); + }); + + ui.screen.bind( "vclick", $.proxy( this, "_eatEventAndClose" ) ); + + $.each( this._globalHandlers, function( idx, value ) { + value.src.bind( value.handler ); + }); + }, + + _applyTheme: function( dst, theme, prefix ) { + var classes = ( dst.attr( "class" ) || "").split( " " ), + alreadyAdded = true, + currentTheme = null, + matches, + themeStr = String( theme ); + + while ( classes.length > 0 ) { + currentTheme = classes.pop(); + matches = ( new RegExp( "^ui-" + prefix + "-([a-z])$" ) ).exec( currentTheme ); + if ( matches && matches.length > 1 ) { + currentTheme = matches[ 1 ]; + break; + } else { + currentTheme = null; + } + } + + if ( theme !== currentTheme ) { + dst.removeClass( "ui-" + prefix + "-" + currentTheme ); + if ( ! ( theme === null || theme === "none" ) ) { + dst.addClass( "ui-" + prefix + "-" + themeStr ); + } + } + }, + + _setTheme: function( value ) { + this._applyTheme( this.element, value, "body" ); + }, + + _setOverlayTheme: function( value ) { + this._applyTheme( this._ui.screen, value, "overlay" ); + + if ( this._isOpen ) { + this._ui.screen.addClass( "in" ); + } + }, + + _setShadow: function( value ) { + this.element.toggleClass( "ui-overlay-shadow", value ); + }, + + _setCorners: function( value ) { + this.element.toggleClass( "ui-corner-all", value ); + }, + + _applyTransition: function( value ) { + this._ui.container.removeClass( this._fallbackTransition ); + if ( value && value !== "none" ) { + this._fallbackTransition = $.mobile._maybeDegradeTransition( value ); + if ( this._fallbackTransition === "none" ) { + this._fallbackTransition = ""; + } + this._ui.container.addClass( this._fallbackTransition ); + } + }, + + _setTransition: function( value ) { + if ( !this._currentTransition ) { + this._applyTransition( value ); + } + }, + + _setTolerance: function( value ) { + var tol = { t: 30, r: 15, b: 30, l: 15 }; + + if ( value ) { + var ar = String( value ).split( "," ); + + $.each( ar, function( idx, val ) { ar[ idx ] = parseInt( val, 10 ); } ); + + switch( ar.length ) { + // All values are to be the same + case 1: + if ( !isNaN( ar[ 0 ] ) ) { + tol.t = tol.r = tol.b = tol.l = ar[ 0 ]; + } + break; + + // The first value denotes top/bottom tolerance, and the second value denotes left/right tolerance + case 2: + if ( !isNaN( ar[ 0 ] ) ) { + tol.t = tol.b = ar[ 0 ]; + } + if ( !isNaN( ar[ 1 ] ) ) { + tol.l = tol.r = ar[ 1 ]; + } + break; + + // The array contains values in the order top, right, bottom, left + case 4: + if ( !isNaN( ar[ 0 ] ) ) { + tol.t = ar[ 0 ]; + } + if ( !isNaN( ar[ 1 ] ) ) { + tol.r = ar[ 1 ]; + } + if ( !isNaN( ar[ 2 ] ) ) { + tol.b = ar[ 2 ]; + } + if ( !isNaN( ar[ 3 ] ) ) { + tol.l = ar[ 3 ]; + } + break; + + default: + break; + } + } + + this._tolerance = tol; + }, + + _setOption: function( key, value ) { + var exclusions, setter = "_set" + key.charAt( 0 ).toUpperCase() + key.slice( 1 ); + + if ( this[ setter ] !== undefined ) { + this[ setter ]( value ); + } + + // TODO REMOVE FOR 1.2.1 by moving them out to a default options object + exclusions = [ + "initSelector", + "closeLinkSelector", + "closeLinkEvents", + "navigateEvents", + "closeEvents", + "history", + "container" + ]; + + $.mobile.widget.prototype._setOption.apply( this, arguments ); + if ( $.inArray( key, exclusions ) === -1 ) { + // Record the option change in the options and in the DOM data-* attributes + this.element.attr( "data-" + ( $.mobile.ns || "" ) + ( key.replace( /([A-Z])/, "-$1" ).toLowerCase() ), value ); + } + }, + + // Try and center the overlay over the given coordinates + _placementCoords: function( desired ) { + // rectangle within which the popup must fit + var + winCoords = windowCoords(), + rc = { + x: this._tolerance.l, + y: winCoords.y + this._tolerance.t, + cx: winCoords.cx - this._tolerance.l - this._tolerance.r, + cy: winCoords.cy - this._tolerance.t - this._tolerance.b + }, + menuSize, ret; + + // Clamp the width of the menu before grabbing its size + this._ui.container.css( "max-width", rc.cx ); + menuSize = { + cx: this._ui.container.outerWidth( true ), + cy: this._ui.container.outerHeight( true ) + }; + + // Center the menu over the desired coordinates, while not going outside + // the window tolerances. This will center wrt. the window if the popup is too large. + ret = { + x: fitSegmentInsideSegment( rc.cx, menuSize.cx, rc.x, desired.x ), + y: fitSegmentInsideSegment( rc.cy, menuSize.cy, rc.y, desired.y ) + }; + + // Make sure the top of the menu is visible + ret.y = Math.max( 0, ret.y ); + + // If the height of the menu is smaller than the height of the document + // align the bottom with the bottom of the document + + // fix for $( document ).height() bug in core 1.7.2. + var docEl = document.documentElement, docBody = document.body, + docHeight = Math.max( docEl.clientHeight, docBody.scrollHeight, docBody.offsetHeight, docEl.scrollHeight, docEl.offsetHeight ); + + ret.y -= Math.min( ret.y, Math.max( 0, ret.y + menuSize.cy - docHeight ) ); + + return { left: ret.x, top: ret.y }; + }, + + _createPrereqs: function( screenPrereq, containerPrereq, whenDone ) { + var self = this, prereqs; + + // It is important to maintain both the local variable prereqs and self._prereqs. The local variable remains in + // the closure of the functions which call the callbacks passed in. The comparison between the local variable and + // self._prereqs is necessary, because once a function has been passed to .animationComplete() it will be called + // next time an animation completes, even if that's not the animation whose end the function was supposed to catch + // (for example, if an abort happens during the opening animation, the .animationComplete handler is not called for + // that animation anymore, but the handler remains attached, so it is called the next time the popup is opened + // - making it stale. Comparing the local variable prereqs to the widget-level variable self._prereqs ensures that + // callbacks triggered by a stale .animationComplete will be ignored. + + prereqs = { + screen: $.Deferred(), + container: $.Deferred() + }; + + prereqs.screen.then( function() { + if ( prereqs === self._prereqs ) { + screenPrereq(); + } + }); + + prereqs.container.then( function() { + if ( prereqs === self._prereqs ) { + containerPrereq(); + } + }); + + $.when( prereqs.screen, prereqs.container ).done( function() { + if ( prereqs === self._prereqs ) { + self._prereqs = null; + whenDone(); + } + }); + + self._prereqs = prereqs; + }, + + _animate: function( args ) { + // NOTE before removing the default animation of the screen + // this had an animate callback that would resolve the deferred + // now the deferred is resolved immediately + // TODO remove the dependency on the screen deferred + this._ui.screen + .removeClass( args.classToRemove ) + .addClass( args.screenClassToAdd ); + + args.prereqs.screen.resolve(); + + if ( args.transition && args.transition !== "none" ) { + if ( args.applyTransition ) { + this._applyTransition( args.transition ); + } + if ( this._fallbackTransition ) { + this._ui.container + .animationComplete( $.proxy( args.prereqs.container, "resolve" ) ) + .addClass( args.containerClassToAdd ) + .removeClass( args.classToRemove ); + return; + } + } + this._ui.container.removeClass( args.classToRemove ); + args.prereqs.container.resolve(); + }, + + // The desired coordinates passed in will be returned untouched if no reference element can be identified via + // desiredPosition.positionTo. Nevertheless, this function ensures that its return value always contains valid + // x and y coordinates by specifying the center middle of the window if the coordinates are absent. + _desiredCoords: function( x, y, positionTo ) { + var dst = null, offset, winCoords = windowCoords(); + + // Establish which element will serve as the reference + if ( positionTo && positionTo !== "origin" ) { + if ( positionTo === "window" ) { + x = winCoords.cx / 2 + winCoords.x; + y = winCoords.cy / 2 + winCoords.y; + } else { + try { + dst = $( positionTo ); + } catch( e ) { + dst = null; + } + if ( dst ) { + dst.filter( ":visible" ); + if ( dst.length === 0 ) { + dst = null; + } + } + } + } + + // If an element was found, center over it + if ( dst ) { + offset = dst.offset(); + x = offset.left + dst.outerWidth() / 2; + y = offset.top + dst.outerHeight() / 2; + } + + // Make sure x and y are valid numbers - center over the window + if ( $.type( x ) !== "number" || isNaN( x ) ) { + x = winCoords.cx / 2 + winCoords.x; + } + if ( $.type( y ) !== "number" || isNaN( y ) ) { + y = winCoords.cy / 2 + winCoords.y; + } + + return { x: x, y: y }; + }, + + _openPrereqsComplete: function() { + var self = this; + + self._ui.container.addClass( "ui-popup-active" ); + self._isOpen = true; + self._resizeScreen(); + + // Android appears to trigger the animation complete before the popup + // is visible. Allowing the stack to unwind before applying focus prevents + // the "blue flash" of element focus in android 4.0 + setTimeout(function(){ + self._ui.container.attr( "tabindex", "0" ).focus(); + self._expectResizeEvent(); + self._trigger( "afteropen" ); + }); + }, + + _open: function( options ) { + var coords, transition, + androidBlacklist = ( function() { + var w = window, + ua = navigator.userAgent, + // Rendering engine is Webkit, and capture major version + wkmatch = ua.match( /AppleWebKit\/([0-9\.]+)/ ), + wkversion = !!wkmatch && wkmatch[ 1 ], + androidmatch = ua.match( /Android (\d+(?:\.\d+))/ ), + andversion = !!androidmatch && androidmatch[ 1 ], + chromematch = ua.indexOf( "Chrome" ) > -1; + + // Platform is Android, WebKit version is greater than 534.13 ( Android 3.2.1 ) and not Chrome. + if( androidmatch !== null && andversion === "4.0" && wkversion && wkversion > 534.13 && !chromematch ) { + return true; + } + return false; + }()); + + // Make sure options is defined + options = ( options || {} ); + + // Copy out the transition, because we may be overwriting it later and we don't want to pass that change back to the caller + transition = options.transition || this.options.transition; + + // Give applications a chance to modify the contents of the container before it appears + this._trigger( "beforeposition" ); + + coords = this._placementCoords( this._desiredCoords( options.x, options.y, options.positionTo || this.options.positionTo || "origin" ) ); + + // Count down to triggering "popupafteropen" - we have two prerequisites: + // 1. The popup window animation completes (container()) + // 2. The screen opacity animation completes (screen()) + this._createPrereqs( + $.noop, + $.noop, + $.proxy( this, "_openPrereqsComplete" ) ); + + if ( transition ) { + this._currentTransition = transition; + this._applyTransition( transition ); + } else { + transition = this.options.transition; + } + + if ( !this.options.theme ) { + this._setTheme( this._page.jqmData( "theme" ) || $.mobile.getInheritedTheme( this._page, "c" ) ); + } + + this._ui.screen.removeClass( "ui-screen-hidden" ); + + this._ui.container + .removeClass( "ui-popup-hidden" ) + .offset( coords ); + + if ( this.options.overlayTheme && androidBlacklist ) { + /* TODO: + The native browser on Android 4.0.X ("Ice Cream Sandwich") suffers from an issue where the popup overlay appears to be z-indexed + above the popup itself when certain other styles exist on the same page -- namely, any element set to `position: fixed` and certain + types of input. These issues are reminiscent of previously uncovered bugs in older versions of Android's native browser: + https://github.com/scottjehl/Device-Bugs/issues/3 + + This fix closes the following bugs ( I use "closes" with reluctance, and stress that this issue should be revisited as soon as possible ): + + https://github.com/jquery/jquery-mobile/issues/4816 + https://github.com/jquery/jquery-mobile/issues/4844 + https://github.com/jquery/jquery-mobile/issues/4874 + */ + + // TODO sort out why this._page isn't working + this.element.closest( ".ui-page" ).addClass( "ui-popup-open" ); + } + this._animate({ + additionalCondition: true, + transition: transition, + classToRemove: "", + screenClassToAdd: "in", + containerClassToAdd: "in", + applyTransition: false, + prereqs: this._prereqs + }); + }, + + _closePrereqScreen: function() { + this._ui.screen + .removeClass( "out" ) + .addClass( "ui-screen-hidden" ); + }, + + _closePrereqContainer: function() { + this._ui.container + .removeClass( "reverse out" ) + .addClass( "ui-popup-hidden" ) + .removeAttr( "style" ); + }, + + _closePrereqsDone: function() { + var self = this, opts = self.options; + + self._ui.container.removeAttr( "tabindex" ); + + // remove nav bindings if they are still present + opts.container.unbind( opts.closeEvents ); + + // unbind click handlers added when history is disabled + self.element.undelegate( opts.closeLinkSelector, opts.closeLinkEvents ); + + // remove the global mutex for popups + $.mobile.popup.active = undefined; + + // alert users that the popup is closed + self._trigger( "afterclose" ); + }, + + _close: function( immediate ) { + this._ui.container.removeClass( "ui-popup-active" ); + this._page.removeClass( "ui-popup-open" ); + + this._isOpen = false; + + // Count down to triggering "popupafterclose" - we have two prerequisites: + // 1. The popup window reverse animation completes (container()) + // 2. The screen opacity animation completes (screen()) + this._createPrereqs( + $.proxy( this, "_closePrereqScreen" ), + $.proxy( this, "_closePrereqContainer" ), + $.proxy( this, "_closePrereqsDone" ) ); + + this._animate( { + additionalCondition: this._ui.screen.hasClass( "in" ), + transition: ( immediate ? "none" : ( this._currentTransition || this.options.transition ) ), + classToRemove: "in", + screenClassToAdd: "out", + containerClassToAdd: "reverse out", + applyTransition: true, + prereqs: this._prereqs + }); + }, + + _unenhance: function() { + var self = this; + + // Put the element back to where the placeholder was and remove the "ui-popup" class + self._setTheme( "none" ); + self.element + // Cannot directly insertAfter() - we need to detach() first, because + // insertAfter() will do nothing if the payload div was not attached + // to the DOM at the time the widget was created, and so the payload + // will remain inside the container even after we call insertAfter(). + // If that happens and we remove the container a few lines below, we + // will cause an infinite recursion - #5244 + .detach() + .insertAfter( self._ui.placeholder ) + .removeClass( "ui-popup ui-overlay-shadow ui-corner-all" ); + self._ui.screen.remove(); + self._ui.container.remove(); + self._ui.placeholder.remove(); + + // Unbind handlers that were bound to elements outside self.element (the window, in self case) + $.each( self._globalHandlers, function( idx, oneSrc ) { + $.each( oneSrc.handler, function( eventType, handler ) { + oneSrc.src.unbind( eventType, handler ); + }); + }); + }, + + _destroy: function() { + if ( $.mobile.popup.active === this ) { + this.element.one( "popupafterclose", $.proxy( this, "_unenhance" ) ); + this.close(); + } else { + this._unenhance(); + } + }, + + _closePopup: function( e, data ) { + var parsedDst, toUrl; + + window.scrollTo( 0, this._scrollTop ); + + if ( e.type === "pagebeforechange" && data ) { + // Determine whether we need to rapid-close the popup, or whether we can + // take the time to run the closing transition + if ( typeof data.toPage === "string" ) { + parsedDst = data.toPage; + } else { + parsedDst = data.toPage.jqmData( "url" ); + } + parsedDst = $.mobile.path.parseUrl( parsedDst ); + toUrl = parsedDst.pathname + parsedDst.search + parsedDst.hash; + + if ( this._myUrl !== toUrl ) { + // Going to a different page - close immediately + this.options.container.unbind( this.options.closeEvents ); + this._close( true ); + } else { + this.close(); + e.preventDefault(); + } + + return; + } + + this._close(); + }, + + // any navigation event after a popup is opened should close the popup + // NOTE the pagebeforechange is bound to catch navigation events that don't + // alter the url (eg, dialogs from popups) + _bindContainerClose: function() { + var self = this; + + self.options.container + .one( self.options.closeEvents, $.proxy( self, "_closePopup" ) ); + }, + + // TODO no clear deliniation of what should be here and + // what should be in _open. Seems to be "visual" vs "history" for now + open: function( options ) { + var self = this, opts = this.options, url, hashkey, activePage, currentIsDialog, hasHash, urlHistory; + + // make sure open is idempotent + if( $.mobile.popup.active ) { + return; + } + + // set the global popup mutex + $.mobile.popup.active = this; + this._scrollTop = $( window ).scrollTop(); + + // if history alteration is disabled close on navigate events + // and leave the url as is + if( !( opts.history ) ) { + self._open( options ); + self._bindContainerClose(); + + // When histoy is disabled we have to grab the data-rel + // back link clicks so we can close the popup instead of + // relying on history to do it for us + self.element + .delegate( opts.closeLinkSelector, opts.closeLinkEvents, function( e ) { + self._close(); + + // NOTE prevent the browser and navigation handlers from + // working with the link's rel=back. This may cause + // issues for developers expecting the event to bubble + return false; + }); + + return; + } + + // cache some values for min/readability + hashkey = $.mobile.dialogHashKey; + activePage = $.mobile.activePage; + currentIsDialog = activePage.is( ".ui-dialog" ); + this._myUrl = url = $.mobile.urlHistory.getActive().url; + hasHash = ( url.indexOf( hashkey ) > -1 ) && !currentIsDialog; + urlHistory = $.mobile.urlHistory; + + if ( hasHash ) { + self._open( options ); + self._bindContainerClose(); + return; + } + + url = url + hashkey; + + // Tack on an extra hashkey if this is the first page and we've just reconstructed the initial hash + if ( urlHistory.activeIndex === 0 && url === urlHistory.initialDst ) { + url += hashkey; + } + + // swallow the the initial navigation event, and bind for the next + opts.container.one( opts.navigateEvents, function( e ) { + e.preventDefault(); + self._open( options ); + self._bindContainerClose(); + }); + + urlHistory.ignoreNextHashChange = currentIsDialog; + + // Gotta love methods with 1mm args :( + urlHistory.addNew( url, undefined, undefined, undefined, "dialog" ); + + // set the new url with (or without) the new dialog hash key + $.mobile.path.set( url ); + }, + + close: function() { + // make sure close is idempotent + if( !$.mobile.popup.active ){ + return; + } + + this._scrollTop = $( window ).scrollTop(); + + if( this.options.history ) { + $.mobile.back(); + } else { + this._close(); + } + } + }); + + + // TODO this can be moved inside the widget + $.mobile.popup.handleLink = function( $link ) { + var closestPage = $link.closest( ":jqmData(role='page')" ), + scope = ( ( closestPage.length === 0 ) ? $( "body" ) : closestPage ), + // NOTE make sure to get only the hash, ie7 (wp7) return the absolute href + // in this case ruining the element selection + popup = $( $.mobile.path.parseUrl($link.attr( "href" )).hash, scope[0] ), + offset; + + if ( popup.data( "popup" ) ) { + offset = $link.offset(); + popup.popup( "open", { + x: offset.left + $link.outerWidth() / 2, + y: offset.top + $link.outerHeight() / 2, + transition: $link.jqmData( "transition" ), + positionTo: $link.jqmData( "position-to" ), + link: $link + }); + } + + //remove after delay + setTimeout( function() { + // Check if we are in a listview + var $parent = $link.parent().parent(); + if ($parent.hasClass("ui-li")) { + $link = $parent.parent(); + } + $link.removeClass( $.mobile.activeBtnClass ); + }, 300 ); + }; + + // TODO move inside _create + $( document ).bind( "pagebeforechange", function( e, data ) { + if ( data.options.role === "popup" ) { + $.mobile.popup.handleLink( data.options.link ); + e.preventDefault(); + } + }); + + $( document ).bind( "pagecreate create", function( e ) { + $.mobile.popup.prototype.enhanceWithin( e.target, true ); + }); + +})( jQuery ); + +(function( $ ) { + var meta = $( "meta[name=viewport]" ), + initialContent = meta.attr( "content" ), + disabledZoom = initialContent + ",maximum-scale=1, user-scalable=no", + enabledZoom = initialContent + ",maximum-scale=10, user-scalable=yes", + disabledInitially = /(user-scalable[\s]*=[\s]*no)|(maximum-scale[\s]*=[\s]*1)[$,\s]/.test( initialContent ); + + $.mobile.zoom = $.extend( {}, { + enabled: !disabledInitially, + locked: false, + disable: function( lock ) { + if ( !disabledInitially && !$.mobile.zoom.locked ) { + meta.attr( "content", disabledZoom ); + $.mobile.zoom.enabled = false; + $.mobile.zoom.locked = lock || false; + } + }, + enable: function( unlock ) { + if ( !disabledInitially && ( !$.mobile.zoom.locked || unlock === true ) ) { + meta.attr( "content", enabledZoom ); + $.mobile.zoom.enabled = true; + $.mobile.zoom.locked = false; + } + }, + restore: function() { + if ( !disabledInitially ) { + meta.attr( "content", initialContent ); + $.mobile.zoom.enabled = true; + } + } + }); + +}( jQuery )); + +(function( $, undefined ) { + +$.widget( "mobile.textinput", $.mobile.widget, { + options: { + theme: null, + mini: false, + // This option defaults to true on iOS devices. + preventFocusZoom: /iPhone|iPad|iPod/.test( navigator.platform ) && navigator.userAgent.indexOf( "AppleWebKit" ) > -1, + initSelector: "input[type='text'], input[type='search'], :jqmData(type='search'), input[type='number'], :jqmData(type='number'), input[type='password'], input[type='email'], input[type='url'], input[type='tel'], textarea, input[type='time'], input[type='date'], input[type='month'], input[type='week'], input[type='datetime'], input[type='datetime-local'], input[type='color'], input:not([type])", + clearSearchButtonText: "clear text", + disabled: false + }, + + _create: function() { + + var self = this, + input = this.element, + o = this.options, + theme = o.theme || $.mobile.getInheritedTheme( this.element, "c" ), + themeclass = " ui-body-" + theme, + miniclass = o.mini ? " ui-mini" : "", + focusedEl, clearbtn; + + function toggleClear() { + setTimeout( function() { + clearbtn.toggleClass( "ui-input-clear-hidden", !input.val() ); + }, 0 ); + } + + $( "label[for='" + input.attr( "id" ) + "']" ).addClass( "ui-input-text" ); + + focusedEl = input.addClass("ui-input-text ui-body-"+ theme ); + + // XXX: Temporary workaround for issue 785 (Apple bug 8910589). + // Turn off autocorrect and autocomplete on non-iOS 5 devices + // since the popup they use can't be dismissed by the user. Note + // that we test for the presence of the feature by looking for + // the autocorrect property on the input element. We currently + // have no test for iOS 5 or newer so we're temporarily using + // the touchOverflow support flag for jQM 1.0. Yes, I feel dirty. - jblas + if ( typeof input[0].autocorrect !== "undefined" && !$.support.touchOverflow ) { + // Set the attribute instead of the property just in case there + // is code that attempts to make modifications via HTML. + input[0].setAttribute( "autocorrect", "off" ); + input[0].setAttribute( "autocomplete", "off" ); + } + + + //"search" input widget + if ( input.is( "[type='search'],:jqmData(type='search')" ) ) { + + focusedEl = input.wrap( "" ).parent(); + clearbtn = $( "
" + o.clearSearchButtonText + "" ) + .bind('click', function( event ) { + input + .val( "" ) + .focus() + .trigger( "change" ); + clearbtn.addClass( "ui-input-clear-hidden" ); + event.preventDefault(); + }) + .appendTo( focusedEl ) + .buttonMarkup({ + icon: "delete", + iconpos: "notext", + corners: true, + shadow: true, + mini: o.mini + }); + + toggleClear(); + + input.bind( 'paste cut keyup focus change blur', toggleClear ); + + } else { + input.addClass( "ui-corner-all ui-shadow-inset" + themeclass + miniclass ); + } + + input.focus(function() { + focusedEl.addClass( $.mobile.focusClass ); + }) + .blur(function() { + focusedEl.removeClass( $.mobile.focusClass ); + }) + // In many situations, iOS will zoom into the select upon tap, this prevents that from happening + .bind( "focus", function() { + if ( o.preventFocusZoom ) { + $.mobile.zoom.disable( true ); + } + }) + .bind( "blur", function() { + if ( o.preventFocusZoom ) { + $.mobile.zoom.enable( true ); + } + }); + + // Autogrow + if ( input.is( "textarea" ) ) { + var extraLineHeight = 15, + keyupTimeoutBuffer = 100, + keyupTimeout; + + this._keyup = function() { + var scrollHeight = input[ 0 ].scrollHeight, + clientHeight = input[ 0 ].clientHeight; + + if ( clientHeight < scrollHeight ) { + input.height(scrollHeight + extraLineHeight); + } + }; + + input.keyup(function() { + clearTimeout( keyupTimeout ); + keyupTimeout = setTimeout( self._keyup, keyupTimeoutBuffer ); + }); + + // binding to pagechange here ensures that for pages loaded via + // ajax the height is recalculated without user input + this._on( $(document), {"pagechange": "_keyup" }); + + // Issue 509: the browser is not providing scrollHeight properly until the styles load + if ( $.trim( input.val() ) ) { + // bind to the window load to make sure the height is calculated based on BOTH + // the DOM and CSS + this._on( $(window), {"load": "_keyup"}); + } + } + if ( input.attr( "disabled" ) ) { + this.disable(); + } + }, + + disable: function() { + var $el; + if ( this.element.attr( "disabled", true ).is( "[type='search'], :jqmData(type='search')" ) ) { + $el = this.element.parent(); + } else { + $el = this.element; + } + $el.addClass( "ui-disabled" ); + return this._setOption( "disabled", true ); + }, + + enable: function() { + var $el; + + // TODO using more than one line of code is acceptable ;) + if ( this.element.attr( "disabled", false ).is( "[type='search'], :jqmData(type='search')" ) ) { + $el = this.element.parent(); + } else { + $el = this.element; + } + $el.removeClass( "ui-disabled" ); + return this._setOption( "disabled", false ); + } +}); + +//auto self-init widgets +$( document ).bind( "pagecreate create", function( e ) { + $.mobile.textinput.prototype.enhanceWithin( e.target, true ); +}); + +})( jQuery ); + +(function( $, undefined ) { + +$.mobile.listview.prototype.options.filter = false; +$.mobile.listview.prototype.options.filterPlaceholder = "Filter items..."; +$.mobile.listview.prototype.options.filterTheme = "c"; +// TODO rename callback/deprecate and default to the item itself as the first argument +var defaultFilterCallback = function( text, searchValue, item ) { + return text.toString().toLowerCase().indexOf( searchValue ) === -1; + }; + +$.mobile.listview.prototype.options.filterCallback = defaultFilterCallback; + +$( document ).delegate( "ul, ol", "listviewcreate", function() { + + var list = $( this ), + listview = list.data( "listview" ); + + if ( !listview.options.filter ) { + return; + } + + var wrapper = $( "
", { + "class": "ui-listview-filter ui-bar-" + listview.options.filterTheme, + "role": "search" + }).submit( function( e ) { + e.preventDefault(); + search.blur(); + }), + search = $( "", { + placeholder: listview.options.filterPlaceholder + }) + .attr( "data-" + $.mobile.ns + "type", "search" ) + .jqmData( "lastval", "" ) + .bind( "keyup change", function() { + + var $this = $( this ), + val = this.value.toLowerCase(), + listItems = null, + lastval = $this.jqmData( "lastval" ) + "", + childItems = false, + itemtext = "", + item, + // Check if a custom filter callback applies + isCustomFilterCallback = listview.options.filterCallback !== defaultFilterCallback; + + listview._trigger( "beforefilter", "beforefilter", { input: this } ); + + // Change val as lastval for next execution + $this.jqmData( "lastval" , val ); + if ( isCustomFilterCallback || val.length < lastval.length || val.indexOf( lastval ) !== 0 ) { + + // Custom filter callback applies or removed chars or pasted something totally different, check all items + listItems = list.children(); + } else { + + // Only chars added, not removed, only use visible subset + listItems = list.children( ":not(.ui-screen-hidden)" ); + } + + if ( val ) { + + // This handles hiding regular rows without the text we search for + // and any list dividers without regular rows shown under it + + for ( var i = listItems.length - 1; i >= 0; i-- ) { + item = $( listItems[ i ] ); + itemtext = item.jqmData( "filtertext" ) || item.text(); + + if ( item.is( "li:jqmData(role=list-divider)" ) ) { + + item.toggleClass( "ui-filter-hidequeue" , !childItems ); + + // New bucket! + childItems = false; + + } else if ( listview.options.filterCallback( itemtext, val, item ) ) { + + //mark to be hidden + item.toggleClass( "ui-filter-hidequeue" , true ); + } else { + + // There's a shown item in the bucket + childItems = true; + } + } + + // Show items, not marked to be hidden + listItems + .filter( ":not(.ui-filter-hidequeue)" ) + .toggleClass( "ui-screen-hidden", false ); + + // Hide items, marked to be hidden + listItems + .filter( ".ui-filter-hidequeue" ) + .toggleClass( "ui-screen-hidden", true ) + .toggleClass( "ui-filter-hidequeue", false ); + + } else { + + //filtervalue is empty => show all + listItems.toggleClass( "ui-screen-hidden", false ); + } + listview._refreshCorners(); + }) + .appendTo( wrapper ) + .textinput(); + + if ( listview.options.inset ) { + wrapper.addClass( "ui-listview-filter-inset" ); + } + + wrapper.bind( "submit", function() { + return false; + }) + .insertBefore( list ); +}); + +})( jQuery ); + +(function( $, undefined ) { + +$.widget( "mobile.slider", $.mobile.widget, { + options: { + theme: null, + trackTheme: null, + disabled: false, + initSelector: "input[type='range'], :jqmData(type='range'), :jqmData(role='slider')", + mini: false + }, + + _create: function() { + + // TODO: Each of these should have comments explain what they're for + var self = this, + + control = this.element, + + parentTheme = $.mobile.getInheritedTheme( control, "c" ), + + theme = this.options.theme || parentTheme, + + trackTheme = this.options.trackTheme || parentTheme, + + cType = control[ 0 ].nodeName.toLowerCase(), + + selectClass = ( cType === "select" ) ? "ui-slider-switch" : "", + + controlID = control.attr( "id" ), + + $label = $( "[for='" + controlID + "']" ), + + labelID = $label.attr( "id" ) || controlID + "-label", + + label = $label.attr( "id", labelID ), + + val = function() { + return cType === "input" ? parseFloat( control.val() ) : control[0].selectedIndex; + }, + + min = cType === "input" ? parseFloat( control.attr( "min" ) ) : 0, + + max = cType === "input" ? parseFloat( control.attr( "max" ) ) : control.find( "option" ).length-1, + + step = window.parseFloat( control.attr( "step" ) || 1 ), + + inlineClass = ( this.options.inline || control.jqmData( "inline" ) === true ) ? " ui-slider-inline" : "", + + miniClass = ( this.options.mini || control.jqmData( "mini" ) ) ? " ui-slider-mini" : "", + + + domHandle = document.createElement( 'a' ), + handle = $( domHandle ), + domSlider = document.createElement( 'div' ), + slider = $( domSlider ), + + valuebg = control.jqmData( "highlight" ) && cType !== "select" ? (function() { + var bg = document.createElement('div'); + bg.className = 'ui-slider-bg ' + $.mobile.activeBtnClass + ' ui-btn-corner-all'; + return $( bg ).prependTo( slider ); + })() : false, + + options; + + this._type = cType; + + domHandle.setAttribute( 'href', "#" ); + domSlider.setAttribute('role','application'); + domSlider.className = ['ui-slider ',selectClass," ui-btn-down-",trackTheme,' ui-btn-corner-all', inlineClass, miniClass].join( "" ); + domHandle.className = 'ui-slider-handle'; + domSlider.appendChild( domHandle ); + + handle.buttonMarkup({ corners: true, theme: theme, shadow: true }) + .attr({ + "role": "slider", + "aria-valuemin": min, + "aria-valuemax": max, + "aria-valuenow": val(), + "aria-valuetext": val(), + "title": val(), + "aria-labelledby": labelID + }); + + $.extend( this, { + slider: slider, + handle: handle, + valuebg: valuebg, + dragging: false, + beforeStart: null, + userModified: false, + mouseMoved: false + }); + + if ( cType === "select" ) { + var wrapper = document.createElement('div'); + wrapper.className = 'ui-slider-inneroffset'; + + for ( var j = 0,length = domSlider.childNodes.length;j < length;j++ ) { + wrapper.appendChild( domSlider.childNodes[j] ); + } + + domSlider.appendChild( wrapper ); + + // slider.wrapInner( "
" ); + + // make the handle move with a smooth transition + handle.addClass( "ui-slider-handle-snapping" ); + + options = control.find( "option" ); + + for ( var i = 0, optionsCount = options.length; i < optionsCount; i++ ) { + var side = !i ? "b" : "a", + sliderTheme = !i ? " ui-btn-down-" + trackTheme : ( " " + $.mobile.activeBtnClass ), + sliderLabel = document.createElement( 'div' ), + sliderImg = document.createElement( 'span' ); + + sliderImg.className = ['ui-slider-label ui-slider-label-',side,sliderTheme," ui-btn-corner-all"].join( "" ); + sliderImg.setAttribute('role','img'); + sliderImg.appendChild( document.createTextNode( options[i].innerHTML ) ); + $(sliderImg).prependTo( slider ); + } + + self._labels = $( ".ui-slider-label", slider ); + + } + + label.addClass( "ui-slider" ); + + // monitor the input for updated values + control.addClass( cType === "input" ? "ui-slider-input" : "ui-slider-switch" ) + .change(function() { + // if the user dragged the handle, the "change" event was triggered from inside refresh(); don't call refresh() again + if ( !self.mouseMoved ) { + self.refresh( val(), true ); + } + }) + .keyup(function() { // necessary? + self.refresh( val(), true, true ); + }) + .blur(function() { + self.refresh( val(), true ); + }); + + this._preventDocumentDrag = function( event ) { + // NOTE: we don't do this in refresh because we still want to + // support programmatic alteration of disabled inputs + if ( self.dragging && !self.options.disabled ) { + + // self.mouseMoved must be updated before refresh() because it will be used in the control "change" event + self.mouseMoved = true; + + if ( cType === "select" ) { + // make the handle move in sync with the mouse + handle.removeClass( "ui-slider-handle-snapping" ); + } + + self.refresh( event ); + + // only after refresh() you can calculate self.userModified + self.userModified = self.beforeStart !== control[0].selectedIndex; + return false; + } + } + + this._on( $( document ), { "vmousemove": this._preventDocumentDrag }); + + // it appears the clicking the up and down buttons in chrome on + // range/number inputs doesn't trigger a change until the field is + // blurred. Here we check thif the value has changed and refresh + control.bind( "vmouseup", $.proxy( self._checkedRefresh, self)); + + slider.bind( "vmousedown", function( event ) { + // NOTE: we don't do this in refresh because we still want to + // support programmatic alteration of disabled inputs + if ( self.options.disabled ) { + return false; + } + + self.dragging = true; + self.userModified = false; + self.mouseMoved = false; + + if ( cType === "select" ) { + self.beforeStart = control[0].selectedIndex; + } + + self.refresh( event ); + self._trigger( "start" ); + return false; + }) + .bind( "vclick", false ); + + this._sliderMouseUp = function() { + if ( self.dragging ) { + self.dragging = false; + + if ( cType === "select") { + // make the handle move with a smooth transition + handle.addClass( "ui-slider-handle-snapping" ); + + if ( self.mouseMoved ) { + // this is a drag, change the value only if user dragged enough + if ( self.userModified ) { + self.refresh( self.beforeStart === 0 ? 1 : 0 ); + } + else { + self.refresh( self.beforeStart ); + } + } + else { + // this is just a click, change the value + self.refresh( self.beforeStart === 0 ? 1 : 0 ); + } + } + + self.mouseMoved = false; + self._trigger( "stop" ); + return false; + } + }; + + this._on( slider.add( document ), { "vmouseup": this._sliderMouseUp }); + slider.insertAfter( control ); + + // Only add focus class to toggle switch, sliders get it automatically from ui-btn + if ( cType === 'select' ) { + this.handle.bind({ + focus: function() { + slider.addClass( $.mobile.focusClass ); + }, + + blur: function() { + slider.removeClass( $.mobile.focusClass ); + } + }); + } + + this.handle.bind({ + // NOTE force focus on handle + vmousedown: function() { + $( this ).focus(); + }, + + vclick: false, + + keydown: function( event ) { + var index = val(); + + if ( self.options.disabled ) { + return; + } + + // In all cases prevent the default and mark the handle as active + switch ( event.keyCode ) { + case $.mobile.keyCode.HOME: + case $.mobile.keyCode.END: + case $.mobile.keyCode.PAGE_UP: + case $.mobile.keyCode.PAGE_DOWN: + case $.mobile.keyCode.UP: + case $.mobile.keyCode.RIGHT: + case $.mobile.keyCode.DOWN: + case $.mobile.keyCode.LEFT: + event.preventDefault(); + + if ( !self._keySliding ) { + self._keySliding = true; + $( this ).addClass( "ui-state-active" ); + } + break; + } + + // move the slider according to the keypress + switch ( event.keyCode ) { + case $.mobile.keyCode.HOME: + self.refresh( min ); + break; + case $.mobile.keyCode.END: + self.refresh( max ); + break; + case $.mobile.keyCode.PAGE_UP: + case $.mobile.keyCode.UP: + case $.mobile.keyCode.RIGHT: + self.refresh( index + step ); + break; + case $.mobile.keyCode.PAGE_DOWN: + case $.mobile.keyCode.DOWN: + case $.mobile.keyCode.LEFT: + self.refresh( index - step ); + break; + } + }, // remove active mark + + keyup: function( event ) { + if ( self._keySliding ) { + self._keySliding = false; + $( this ).removeClass( "ui-state-active" ); + } + } + }); + + if ( this._handleFormReset ) { + this._handleFormReset(); + } + this.refresh( undefined, undefined, true ); + }, + + _checkedRefresh: function() { + if( this.value != this._value() ){ + this.refresh( this._value() ); + } + }, + + _value: function() { + return this._type === "input" ? + parseFloat( this.element.val() ) : this.element[0].selectedIndex; + }, + + + _reset: function() { + this.refresh( undefined, false, true ); + }, + + refresh: function( val, isfromControl, preventInputUpdate ) { + + // NOTE: we don't return here because we want to support programmatic + // alteration of the input value, which should still update the slider + if ( this.options.disabled || this.element.attr('disabled')) { + this.disable(); + } + + // set the stored value for comparison later + this.value = this._value(); + + var control = this.element, percent, + cType = control[0].nodeName.toLowerCase(), + min = cType === "input" ? parseFloat( control.attr( "min" ) ) : 0, + max = cType === "input" ? parseFloat( control.attr( "max" ) ) : control.find( "option" ).length - 1, + step = ( cType === "input" && parseFloat( control.attr( "step" ) ) > 0 ) ? parseFloat( control.attr( "step" ) ) : 1; + + if ( typeof val === "object" ) { + var data = val, + // a slight tolerance helped get to the ends of the slider + tol = 8; + if ( !this.dragging || + data.pageX < this.slider.offset().left - tol || + data.pageX > this.slider.offset().left + this.slider.width() + tol ) { + return; + } + percent = Math.round( ( ( data.pageX - this.slider.offset().left ) / this.slider.width() ) * 100 ); + } else { + if ( val == null ) { + val = cType === "input" ? parseFloat( control.val() || 0 ) : control[0].selectedIndex; + } + percent = ( parseFloat( val ) - min ) / ( max - min ) * 100; + } + + if ( isNaN( percent ) ) { + return; + } + + if ( percent < 0 ) { + percent = 0; + } + + if ( percent > 100 ) { + percent = 100; + } + + var newval = ( percent / 100 ) * ( max - min ) + min; + + //from jQuery UI slider, the following source will round to the nearest step + var valModStep = ( newval - min ) % step; + var alignValue = newval - valModStep; + + if ( Math.abs( valModStep ) * 2 >= step ) { + alignValue += ( valModStep > 0 ) ? step : ( -step ); + } + // Since JavaScript has problems with large floats, round + // the final value to 5 digits after the decimal point (see jQueryUI: #4124) + newval = parseFloat( alignValue.toFixed(5) ); + + if ( newval < min ) { + newval = min; + } + + if ( newval > max ) { + newval = max; + } + + this.handle.css( "left", percent + "%" ); + this.handle.attr( { + "aria-valuenow": cType === "input" ? newval : control.find( "option" ).eq( newval ).attr( "value" ), + "aria-valuetext": cType === "input" ? newval : control.find( "option" ).eq( newval ).getEncodedText(), + title: cType === "input" ? newval : control.find( "option" ).eq( newval ).getEncodedText() + }); + + if ( this.valuebg ) { + this.valuebg.css( "width", percent + "%" ); + } + + // drag the label widths + if ( this._labels ) { + var handlePercent = this.handle.width() / this.slider.width() * 100, + aPercent = percent && handlePercent + ( 100 - handlePercent ) * percent / 100, + bPercent = percent === 100 ? 0 : Math.min( handlePercent + 100 - aPercent, 100 ); + + this._labels.each(function() { + var ab = $( this ).is( ".ui-slider-label-a" ); + $( this ).width( ( ab ? aPercent : bPercent ) + "%" ); + }); + } + + if ( !preventInputUpdate ) { + var valueChanged = false; + + // update control"s value + if ( cType === "input" ) { + valueChanged = control.val() !== newval; + control.val( newval ); + } else { + valueChanged = control[ 0 ].selectedIndex !== newval; + control[ 0 ].selectedIndex = newval; + } + if ( !isfromControl && valueChanged ) { + control.trigger( "change" ); + } + } + }, + + enable: function() { + this.element.attr( "disabled", false ); + this.slider.removeClass( "ui-disabled" ).attr( "aria-disabled", false ); + return this._setOption( "disabled", false ); + }, + + disable: function() { + this.element.attr( "disabled", true ); + this.slider.addClass( "ui-disabled" ).attr( "aria-disabled", true ); + return this._setOption( "disabled", true ); + } + +}); + +$.widget( "mobile.slider", $.mobile.slider, $.mobile.behaviors.formReset ); + +// FIXME: Move the declaration of widgetEventPrefix back to the top of the +// initial declaration of the slider widget once we start using a version of +// the widget factory that includes a fix for http://bugs.jqueryui.com/ticket/8724 +$.widget( "mobile.slider", $.mobile.slider, { widgetEventPrefix: "slide" } ); + +//auto self-init widgets +$( document ).bind( "pagecreate create", function( e ) { + $.mobile.slider.prototype.enhanceWithin( e.target, true ); +}); + +})( jQuery ); + +(function( $, undefined ) { + +$.widget( "mobile.selectmenu", $.mobile.widget, { + options: { + theme: null, + disabled: false, + icon: "arrow-d", + iconpos: "right", + inline: false, + corners: true, + shadow: true, + iconshadow: true, + overlayTheme: "a", + hidePlaceholderMenuItems: true, + closeText: "Close", + nativeMenu: true, + // This option defaults to true on iOS devices. + preventFocusZoom: /iPhone|iPad|iPod/.test( navigator.platform ) && navigator.userAgent.indexOf( "AppleWebKit" ) > -1, + initSelector: "select:not( :jqmData(role='slider') )", + mini: false + }, + + _button: function() { + return $( "
" ); + }, + + _setDisabled: function( value ) { + this.element.attr( "disabled", value ); + this.button.attr( "aria-disabled", value ); + return this._setOption( "disabled", value ); + }, + + _focusButton : function() { + var self = this; + + setTimeout( function() { + self.button.focus(); + }, 40); + }, + + _selectOptions: function() { + return this.select.find( "option" ); + }, + + // setup items that are generally necessary for select menu extension + _preExtension: function() { + var classes = ""; + // TODO: Post 1.1--once we have time to test thoroughly--any classes manually applied to the original element should be carried over to the enhanced element, with an `-enhanced` suffix. See https://github.com/jquery/jquery-mobile/issues/3577 + /* if ( $el[0].className.length ) { + classes = $el[0].className; + } */ + if ( !!~this.element[0].className.indexOf( "ui-btn-left" ) ) { + classes = " ui-btn-left"; + } + + if ( !!~this.element[0].className.indexOf( "ui-btn-right" ) ) { + classes = " ui-btn-right"; + } + + this.select = this.element.wrap( "
" ); + this.selectID = this.select.attr( "id" ); + this.label = $( "label[for='"+ this.selectID +"']" ).addClass( "ui-select" ); + this.isMultiple = this.select[ 0 ].multiple; + if ( !this.options.theme ) { + this.options.theme = $.mobile.getInheritedTheme( this.select, "c" ); + } + }, + + _destroy: function() { + var wrapper = this.element.parents( ".ui-select" ); + if ( wrapper.length > 0 ) { + this.element.insertAfter( wrapper ); + wrapper.remove(); + } + }, + + _create: function() { + this._preExtension(); + + // Allows for extension of the native select for custom selects and other plugins + // see select.custom for example extension + // TODO explore plugin registration + this._trigger( "beforeCreate" ); + + this.button = this._button(); + + var self = this, + + options = this.options, + + inline = options.inline || this.select.jqmData( "inline" ), + mini = options.mini || this.select.jqmData( "mini" ), + iconpos = options.icon ? ( options.iconpos || this.select.jqmData( "iconpos" ) ) : false, + + // IE throws an exception at options.item() function when + // there is no selected item + // select first in this case + selectedIndex = this.select[ 0 ].selectedIndex === -1 ? 0 : this.select[ 0 ].selectedIndex, + + // TODO values buttonId and menuId are undefined here + button = this.button + .insertBefore( this.select ) + .buttonMarkup( { + theme: options.theme, + icon: options.icon, + iconpos: iconpos, + inline: inline, + corners: options.corners, + shadow: options.shadow, + iconshadow: options.iconshadow, + mini: mini + }); + + this.setButtonText(); + + // Opera does not properly support opacity on select elements + // In Mini, it hides the element, but not its text + // On the desktop,it seems to do the opposite + // for these reasons, using the nativeMenu option results in a full native select in Opera + if ( options.nativeMenu && window.opera && window.opera.version ) { + button.addClass( "ui-select-nativeonly" ); + } + + // Add counter for multi selects + if ( this.isMultiple ) { + this.buttonCount = $( "" ) + .addClass( "ui-li-count ui-btn-up-c ui-btn-corner-all" ) + .hide() + .appendTo( button.addClass('ui-li-has-count') ); + } + + // Disable if specified + if ( options.disabled || this.element.attr('disabled')) { + this.disable(); + } + + // Events on native select + this.select.change(function() { + self.refresh(); + }); + + if ( this._handleFormReset ) { + this._handleFormReset(); + } + this.build(); + }, + + build: function() { + var self = this; + + this.select + .appendTo( self.button ) + .bind( "vmousedown", function() { + // Add active class to button + self.button.addClass( $.mobile.activeBtnClass ); + }) + .bind( "focus", function() { + self.button.addClass( $.mobile.focusClass ); + }) + .bind( "blur", function() { + self.button.removeClass( $.mobile.focusClass ); + }) + .bind( "focus vmouseover", function() { + self.button.trigger( "vmouseover" ); + }) + .bind( "vmousemove", function() { + // Remove active class on scroll/touchmove + self.button.removeClass( $.mobile.activeBtnClass ); + }) + .bind( "change blur vmouseout", function() { + self.button.trigger( "vmouseout" ) + .removeClass( $.mobile.activeBtnClass ); + }) + .bind( "change blur", function() { + self.button.removeClass( "ui-btn-down-" + self.options.theme ); + }); + + // In many situations, iOS will zoom into the select upon tap, this prevents that from happening + self.button.bind( "vmousedown", function() { + if ( self.options.preventFocusZoom ) { + $.mobile.zoom.disable( true ); + } + }); + self.label.bind( "click focus", function() { + if ( self.options.preventFocusZoom ) { + $.mobile.zoom.disable( true ); + } + }); + self.select.bind( "focus", function() { + if ( self.options.preventFocusZoom ) { + $.mobile.zoom.disable( true ); + } + }); + self.button.bind( "mouseup", function() { + if ( self.options.preventFocusZoom ) { + setTimeout(function() { + $.mobile.zoom.enable( true ); + }, 0 ); + } + }); + self.select.bind( "blur", function() { + if ( self.options.preventFocusZoom ) { + $.mobile.zoom.enable( true ); + } + }); + + }, + + selected: function() { + return this._selectOptions().filter( ":selected" ); + }, + + selectedIndices: function() { + var self = this; + + return this.selected().map(function() { + return self._selectOptions().index( this ); + }).get(); + }, + + setButtonText: function() { + var self = this, + selected = this.selected(), + text = this.placeholder, + span = $( document.createElement( "span" ) ); + + this.button.find( ".ui-btn-text" ).html(function() { + if ( selected.length ) { + text = selected.map(function() { + return $( this ).text(); + }).get().join( ", " ); + } else { + text = self.placeholder; + } + + // TODO possibly aggregate multiple select option classes + return span.text( text ) + .addClass( self.select.attr( "class" ) ) + .addClass( selected.attr( "class" ) ); + }); + }, + + setButtonCount: function() { + var selected = this.selected(); + + // multiple count inside button + if ( this.isMultiple ) { + this.buttonCount[ selected.length > 1 ? "show" : "hide" ]().text( selected.length ); + } + }, + + _reset: function() { + this.refresh(); + }, + + refresh: function() { + this.setButtonText(); + this.setButtonCount(); + }, + + // open and close preserved in native selects + // to simplify users code when looping over selects + open: $.noop, + close: $.noop, + + disable: function() { + this._setDisabled( true ); + this.button.addClass( "ui-disabled" ); + }, + + enable: function() { + this._setDisabled( false ); + this.button.removeClass( "ui-disabled" ); + } +}); + +$.widget( "mobile.selectmenu", $.mobile.selectmenu, $.mobile.behaviors.formReset ); + +//auto self-init widgets +$( document ).bind( "pagecreate create", function( e ) { + $.mobile.selectmenu.prototype.enhanceWithin( e.target, true ); +}); +})( jQuery ); + +/* +* custom "selectmenu" plugin +*/ + +(function( $, undefined ) { + var extendSelect = function( widget ) { + + var select = widget.select, + origDestroy = widget._destroy, + selectID = widget.selectID, + label = widget.label, + thisPage = widget.select.closest( ".ui-page" ), + selectOptions = widget._selectOptions(), + isMultiple = widget.isMultiple = widget.select[ 0 ].multiple, + buttonId = selectID + "-button", + menuId = selectID + "-menu", + menuPage = $( "
" + + "
" + + "
" + label.getEncodedText() + "
"+ + "
"+ + "
"+ + "
" ), + + listbox = $( "
", { "class": "ui-selectmenu" } ).insertAfter( widget.select ).popup( { theme: widget.options.overlayTheme } ), + + list = $( "