summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
Diffstat (limited to 'apps')
-rw-r--r--apps/admin_dependencies_chk/settings.php6
-rw-r--r--apps/admin_export/appinfo/info.xml1
-rw-r--r--apps/calendar/ajax/activation.php4
-rw-r--r--apps/calendar/ajax/choosecalendar.php4
-rwxr-xr-xapps/calendar/ajax/daysofweekend.php11
-rw-r--r--apps/calendar/ajax/deletecalendar.php4
-rw-r--r--apps/calendar/ajax/deleteevent.php4
-rw-r--r--apps/calendar/ajax/duration.php12
-rw-r--r--apps/calendar/ajax/editcalendar.php4
-rw-r--r--apps/calendar/ajax/editevent.php4
-rw-r--r--apps/calendar/ajax/editeventform.php166
-rw-r--r--apps/calendar/ajax/events.php2
-rwxr-xr-xapps/calendar/ajax/firstdayofweek.php12
-rw-r--r--apps/calendar/ajax/gettimezonedetection.php11
-rwxr-xr-xapps/calendar/ajax/guesstimezone.php15
-rw-r--r--apps/calendar/ajax/importdialog.php2
-rw-r--r--apps/calendar/ajax/newcalendar.php4
-rw-r--r--apps/calendar/ajax/newevent.php4
-rw-r--r--apps/calendar/ajax/neweventform.php29
-rwxr-xr-xapps/calendar/ajax/setdaysofweekend.php30
-rw-r--r--apps/calendar/ajax/setduration.php17
-rwxr-xr-xapps/calendar/ajax/setfirstdayofweek.php16
-rw-r--r--apps/calendar/ajax/timezonedetection.php17
-rw-r--r--apps/calendar/appinfo/app.php47
-rw-r--r--apps/calendar/index.php7
-rw-r--r--apps/calendar/js/calendar.js124
-rwxr-xr-xapps/calendar/js/geo.js3
-rw-r--r--apps/calendar/js/settings.js64
-rw-r--r--apps/calendar/l10n/xgettextfiles3
-rw-r--r--apps/calendar/lib/app.php41
-rw-r--r--apps/calendar/lib/object.php339
-rw-r--r--apps/calendar/lib/search.php27
-rw-r--r--apps/calendar/resettimezone.php4
-rwxr-xr-xapps/calendar/templates/calendar.php11
-rw-r--r--apps/calendar/templates/lAfix.php39
-rw-r--r--apps/calendar/templates/part.eventform.php251
-rw-r--r--apps/calendar/templates/settings.php2
-rw-r--r--apps/contacts/ajax/addproperty.php20
-rw-r--r--apps/contacts/ajax/contacts.php18
-rw-r--r--apps/contacts/css/styles.css3
-rw-r--r--apps/contacts/index.php31
-rw-r--r--apps/contacts/js/LICENSE.jquery.inview41
-rw-r--r--apps/contacts/js/interface.js34
-rw-r--r--apps/contacts/js/jquery.inview.txt15
-rw-r--r--apps/contacts/lib/addressbook.php41
-rw-r--r--apps/contacts/lib/vcard.php18
-rw-r--r--apps/contacts/templates/part.property.php5
-rw-r--r--apps/contacts/templates/part.setpropertyform.php2
-rw-r--r--apps/contacts/thumbnail.php104
-rw-r--r--apps/files_sharing/sharedstorage.php20
-rw-r--r--apps/gallery/ajax/cover.php22
-rw-r--r--apps/gallery/ajax/createAlbum.php22
-rw-r--r--apps/gallery/ajax/galleryOp.php26
-rw-r--r--apps/gallery/ajax/getAlbums.php22
-rw-r--r--apps/gallery/ajax/getCovers.php22
-rw-r--r--apps/gallery/ajax/scanForAlbums.php23
-rw-r--r--apps/gallery/ajax/thumbnail.php22
-rw-r--r--apps/gallery/appinfo/app.php25
-rw-r--r--apps/gallery/appinfo/database.xml6
-rw-r--r--apps/gallery/appinfo/info.xml9
-rw-r--r--apps/gallery/css/styles.css69
-rw-r--r--apps/gallery/index.php22
-rw-r--r--apps/gallery/js/album_cover.js4
-rw-r--r--apps/gallery/lib/album.php38
-rw-r--r--apps/gallery/lib/hooks_handlers.php118
-rw-r--r--apps/gallery/lib/images_utils.php22
-rw-r--r--apps/gallery/lib/photo.php38
-rw-r--r--apps/gallery/lib/scanner.php27
-rw-r--r--apps/gallery/templates/index.php5
-rw-r--r--apps/media/css/music.css4
-rw-r--r--apps/media/js/jQuery.jPlayer.2.1.0.source/Jplayer.as415
-rw-r--r--apps/media/js/jQuery.jPlayer.2.1.0.source/Jplayer.flabin0 -> 61952 bytes
-rw-r--r--apps/media/js/jQuery.jPlayer.2.1.0.source/add-on/jplayer.playlist.js452
-rw-r--r--apps/media/js/jQuery.jPlayer.2.1.0.source/add-on/jquery.jplayer.inspector.js331
-rw-r--r--apps/media/js/jQuery.jPlayer.2.1.0.source/happyworm/jPlayer/JplayerEvent.as69
-rw-r--r--apps/media/js/jQuery.jPlayer.2.1.0.source/happyworm/jPlayer/JplayerMp3.as328
-rw-r--r--apps/media/js/jQuery.jPlayer.2.1.0.source/happyworm/jPlayer/JplayerMp4.as413
-rw-r--r--apps/media/js/jQuery.jPlayer.2.1.0.source/happyworm/jPlayer/JplayerStatus.as101
-rw-r--r--apps/media/js/jQuery.jPlayer.2.1.0.source/jquery.jplayer.js2349
-rw-r--r--apps/media/js/player.js4
-rw-r--r--apps/media/js/playlist.js16
-rw-r--r--apps/media/lib_collection.php8
-rw-r--r--apps/media/lib_scanner.php97
-rw-r--r--apps/user_webfinger/appinfo/install.php2
84 files changed, 6249 insertions, 575 deletions
diff --git a/apps/admin_dependencies_chk/settings.php b/apps/admin_dependencies_chk/settings.php
index 34028056dbe..ce90dd604ca 100644
--- a/apps/admin_dependencies_chk/settings.php
+++ b/apps/admin_dependencies_chk/settings.php
@@ -45,12 +45,6 @@ $modules[] =array(
'message'=> $l->t('The php-gd module is needed to create thumbnails of your images'));
$modules[] =array(
- 'status' => OC_Helper::canExecute("mp3info") ? 'ok' : 'warning',
- 'part'=> 'mp3info',
- 'modules'=> array('media'),
- 'message'=> $l->t('The program mp3info is useful to discover ID3 tags of your music files'));
-
-$modules[] =array(
'status' => function_exists("ldap_bind") ? 'ok' : 'error',
'part'=> 'php-ldap',
'modules'=> array('user_ldap'),
diff --git a/apps/admin_export/appinfo/info.xml b/apps/admin_export/appinfo/info.xml
index c4a2a9b398c..df8a07c2f5b 100644
--- a/apps/admin_export/appinfo/info.xml
+++ b/apps/admin_export/appinfo/info.xml
@@ -7,4 +7,5 @@
<licence>AGPL</licence>
<author>Thomas Schmidt</author>
<require>2</require>
+ <default_enable/>
</info>
diff --git a/apps/calendar/ajax/activation.php b/apps/calendar/ajax/activation.php
index 3c2bc6de23f..ada2e44547b 100644
--- a/apps/calendar/ajax/activation.php
+++ b/apps/calendar/ajax/activation.php
@@ -7,9 +7,7 @@
*/
require_once ("../../../lib/base.php");
-if(!OC_USER::isLoggedIn()) {
- die("<script type=\"text/javascript\">document.location = oc_webroot;</script>");
-}
+OC_JSON::checkLoggedIn();
OC_JSON::checkAppEnabled('calendar');
$calendarid = $_POST['calendarid'];
$calendar = OC_Calendar_App::getCalendar($calendarid);//access check
diff --git a/apps/calendar/ajax/choosecalendar.php b/apps/calendar/ajax/choosecalendar.php
index 0935a4c42ad..9281c8edbdc 100644
--- a/apps/calendar/ajax/choosecalendar.php
+++ b/apps/calendar/ajax/choosecalendar.php
@@ -8,9 +8,7 @@
require_once('../../../lib/base.php');
$l10n = new OC_L10N('calendar');
-if(!OC_USER::isLoggedIn()) {
- die("<script type=\"text/javascript\">document.location = oc_webroot;</script>");
-}
+OC_JSON::checkLoggedIn();
OC_JSON::checkAppEnabled('calendar');
$output = new OC_TEMPLATE("calendar", "part.choosecalendar");
$output -> printpage();
diff --git a/apps/calendar/ajax/daysofweekend.php b/apps/calendar/ajax/daysofweekend.php
deleted file mode 100755
index 606d13b1e1c..00000000000
--- a/apps/calendar/ajax/daysofweekend.php
+++ /dev/null
@@ -1,11 +0,0 @@
-<?php
-/**
- * Copyright (c) 2011 Georg Ehrke <ownclouddev at georgswebsite dot de>
- * This file is licensed under the Affero General Public License version 3 or
- * later.
- * See the COPYING-README file.
- */
-require_once('../../../lib/base.php');
-OC_JSON::checkLoggedIn();
-echo OC_Preferences::getValue( OC_User::getUser(), 'calendar', 'weekend', '{"Monday":"false","Tuesday":"false","Wednesday":"false","Thursday":"false","Friday":"false","Saturday":"true","Sunday":"true"}');
-?>
diff --git a/apps/calendar/ajax/deletecalendar.php b/apps/calendar/ajax/deletecalendar.php
index fc308da6dad..901cbbfcb08 100644
--- a/apps/calendar/ajax/deletecalendar.php
+++ b/apps/calendar/ajax/deletecalendar.php
@@ -7,9 +7,7 @@
*/
require_once('../../../lib/base.php');
-if(!OC_USER::isLoggedIn()) {
- die('<script type="text/javascript">document.location = oc_webroot;</script>');
-}
+OC_JSON::checkLoggedIn();
OC_JSON::checkAppEnabled('calendar');
$cal = $_POST["calendarid"];
diff --git a/apps/calendar/ajax/deleteevent.php b/apps/calendar/ajax/deleteevent.php
index 269f4a47f42..b25a5af1a29 100644
--- a/apps/calendar/ajax/deleteevent.php
+++ b/apps/calendar/ajax/deleteevent.php
@@ -9,9 +9,7 @@ require_once('../../../lib/base.php');
$l10n = new OC_L10N('calendar');
-if(!OC_USER::isLoggedIn()) {
- die('<script type="text/javascript">document.location = oc_webroot;</script>');
-}
+OC_JSON::checkLoggedIn();
OC_JSON::checkAppEnabled('calendar');
$id = $_POST['id'];
diff --git a/apps/calendar/ajax/duration.php b/apps/calendar/ajax/duration.php
deleted file mode 100644
index cdc41388abd..00000000000
--- a/apps/calendar/ajax/duration.php
+++ /dev/null
@@ -1,12 +0,0 @@
-<?php
-/**
- * Copyright (c) 2011 Georg Ehrke <ownclouddev at georgswebsite dot de>
- * This file is licensed under the Affero General Public License version 3 or
- * later.
- * See the COPYING-README file.
- */
-require_once('../../../lib/base.php');
-OC_JSON::checkLoggedIn();
-$duration = OC_Preferences::getValue( OC_User::getUser(), 'calendar', 'duration', "60");
-OC_JSON::encodedPrint(array("duration" => $duration));
-?>
diff --git a/apps/calendar/ajax/editcalendar.php b/apps/calendar/ajax/editcalendar.php
index e44763c9aaa..7aeb5bbe305 100644
--- a/apps/calendar/ajax/editcalendar.php
+++ b/apps/calendar/ajax/editcalendar.php
@@ -7,9 +7,7 @@
*/
require_once('../../../lib/base.php');
-if(!OC_USER::isLoggedIn()) {
- die("<script type=\"text/javascript\">document.location = oc_webroot;</script>");
-}
+OC_JSON::checkLoggedIn();
OC_JSON::checkAppEnabled('calendar');
$calendarcolor_options = OC_Calendar_Calendar::getCalendarColorOptions();
diff --git a/apps/calendar/ajax/editevent.php b/apps/calendar/ajax/editevent.php
index f00ab1d960b..5a487da1758 100644
--- a/apps/calendar/ajax/editevent.php
+++ b/apps/calendar/ajax/editevent.php
@@ -7,9 +7,7 @@
*/
require_once('../../../lib/base.php');
-if(!OC_USER::isLoggedIn()) {
- die('<script type="text/javascript">document.location = oc_webroot;</script>');
-}
+OC_JSON::checkLoggedIn();
OC_JSON::checkAppEnabled('calendar');
$errarr = OC_Calendar_Object::validateRequest($_POST);
diff --git a/apps/calendar/ajax/editeventform.php b/apps/calendar/ajax/editeventform.php
index fe6c6f73570..95cae39c1c2 100644
--- a/apps/calendar/ajax/editeventform.php
+++ b/apps/calendar/ajax/editeventform.php
@@ -42,7 +42,6 @@ switch($dtstart->getDateType()) {
$summary = $vevent->getAsString('SUMMARY');
$location = $vevent->getAsString('LOCATION');
$categories = $vevent->getAsArray('CATEGORIES');
-$repeat = $vevent->getAsString('CATEGORY');
$description = $vevent->getAsString('DESCRIPTION');
foreach($categories as $category){
if (!in_array($category, $category_options)){
@@ -55,10 +54,150 @@ if ($last_modified){
}else{
$lastmodified = 0;
}
+if($data['repeating'] == 1){
+ $rrule = explode(';', $vevent->getAsString('RRULE'));
+ $rrulearr = array();
+ foreach($rrule as $rule){
+ list($attr, $val) = explode('=', $rule);
+ $rrulearr[$attr] = $val;
+ }
+ if(!isset($rrulearr['INTERVAL']) || $rrulearr['INTERVAL'] == ''){
+ $rrulearr['INTERVAL'] = 1;
+ }
+ if(array_key_exists('BYDAY', $rrulearr)){
+ if(substr_count($rrulearr['BYDAY'], ',') == 0){
+ if(strlen($rrulearr['BYDAY']) == 2){
+ $repeat['weekdays'] = array($rrulearr['BYDAY']);
+ }elseif(strlen($rrulearr['BYDAY']) == 3){
+ $repeat['weekofmonth'] = substr($rrulearr['BYDAY'], 0, 1);
+ $repeat['weekdays'] = array(substr($rrulearr['BYDAY'], 1, 2));
+ }elseif(strlen($rrulearr['BYDAY']) == 4){
+ $repeat['weekofmonth'] = substr($rrulearr['BYDAY'], 0, 2);
+ $repeat['weekdays'] = array(substr($rrulearr['BYDAY'], 2, 2));
+ }
+ }else{
+ $byday_days = explode(',', $rrulearr['BYDAY']);
+ foreach($byday_days as $byday_day){
+ if(strlen($byday_day) == 2){
+ $repeat['weekdays'][] = $byday_day;
+ }elseif(strlen($byday_day) == 3){
+ $repeat['weekofmonth'] = substr($byday_day , 0, 1);
+ $repeat['weekdays'][] = substr($byday_day , 1, 2);
+ }elseif(strlen($byday_day) == 4){
+ $repeat['weekofmonth'] = substr($byday_day , 0, 2);
+ $repeat['weekdays'][] = substr($byday_day , 2, 2);
+ }
+ }
+ }
+ }
+ if(array_key_exists('BYMONTHDAY', $rrulearr)){
+ if(substr_count($rrulearr['BYMONTHDAY'], ',') == 0){
+ $repeat['bymonthday'][] = $rrulearr['BYMONTHDAY'];
+ }else{
+ $bymonthdays = explode(',', $rrulearr['BYMONTHDAY']);
+ foreach($bymonthdays as $bymonthday){
+ $repeat['bymonthday'][] = $bymonthday;
+ }
+ }
+ }
+ if(array_key_exists('BYYEARDAY', $rrulearr)){
+ if(substr_count($rrulearr['BYYEARDAY'], ',') == 0){
+ $repeat['byyearday'][] = $rrulearr['BYYEARDAY'];
+ }else{
+ $byyeardays = explode(',', $rrulearr['BYYEARDAY']);
+ foreach($byyeardays as $yearday){
+ $repeat['byyearday'][] = $yearday;
+ }
+ }
+ }
+ if(array_key_exists('BYWEEKNO', $rrulearr)){
+ if(substr_count($rrulearr['BYWEEKNO'], ',') == 0){
+ $repeat['byweekno'][] = (string) $rrulearr['BYWEEKNO'];
+ }else{
+ $byweekno = explode(',', $rrulearr['BYWEEKNO']);
+ foreach($byweekno as $weekno){
+ $repeat['byweekno'][] = (string) $weekno;
+ }
+ }
+ }
+ if(array_key_exists('BYMONTH', $rrulearr)){
+ $months = OC_Calendar_App::getByMonthOptions();
+ if(substr_count($rrulearr['BYMONTH'], ',') == 0){
+ $repeat['bymonth'][] = $months[$month];
+ }else{
+ $bymonth = explode(',', $rrulearr['BYMONTH']);
+ foreach($bymonth as $month){
+ $repeat['bymonth'][] = $months[$month];
+ }
+ }
+ }
+ switch($rrulearr['FREQ']){
+ case 'DAILY':
+ $repeat['repeat'] = 'daily';
+ break;
+ case 'WEEKLY':
+ if($rrulearr['INTERVAL'] % 2 == 0){
+ $repeat['repeat'] = 'biweekly';
+ $rrulearr['INTERVAL'] = $rrulearr['INTERVAL'] / 2;
+ }elseif($rrulearr['BYDAY'] == 'MO,TU,WE,TH,FR'){
+ $repeat['repeat'] = 'weekday';
+ }else{
+ $repeat['repeat'] = 'weekly';
+ }
+ break;
+ case 'MONTHLY':
+ $repeat['repeat'] = 'monthly';
+ if(array_key_exists('BYDAY', $rrulearr)){
+ $repeat['month'] = 'weekday';
+ }else{
+ $repeat['month'] = 'monthday';
+ }
+ break;
+ case 'YEARLY':
+ $repeat['repeat'] = 'yearly';
+ if(array_key_exists('BYMONTH', $rrulearr)){
+ $repeat['year'] = 'bydaymonth';
+ }elseif(array_key_exists('BYWEEKNO', $rrulearr)){
+ $repeat['year'] = 'byweekno';
+ }else{
+ $repeat['year'] = 'byyearday';
+ }
+ }
+ $repeat['interval'] = $rrulearr['INTERVAL'];
+ if(array_key_exists('COUNT', $rrulearr)){
+ $repeat['end'] = 'count';
+ $repeat['count'] = $rrulearr['COUNT'];
+ }elseif(array_key_exists('UNTIL', $rrulearr)){
+ $repeat['end'] = 'date';
+ $endbydate_day = substr($rrulearr['UNTIL'], 6, 2);
+ $endbydate_month = substr($rrulearr['UNTIL'], 4, 2);
+ $endbydate_year = substr($rrulearr['UNTIL'], 0, 4);
+ $repeat['date'] = $endbydate_day . '-' . $endbydate_month . '-' . $endbydate_year;
+ }else{
+ $repeat['end'] = 'never';
+ }
+ if(array_key_exists('weekdays', $repeat)){
+ $repeat_weekdays_ = array();
+ $days = OC_Calendar_App::getWeeklyOptions();
+ foreach($repeat['weekdays'] as $weekday){
+ $repeat_weekdays_[] = $days[$weekday];
+ }
+ $repeat['weekdays'] = $repeat_weekdays_;
+ }
+}
$calendar_options = OC_Calendar_Calendar::allCalendars(OC_User::getUser());
$category_options = OC_Calendar_App::getCategoryOptions();
$repeat_options = OC_Calendar_App::getRepeatOptions();
+$repeat_end_options = OC_Calendar_App::getEndOptions();
+$repeat_month_options = OC_Calendar_App::getMonthOptions();
+$repeat_year_options = OC_Calendar_App::getYearOptions();
+$repeat_weekly_options = OC_Calendar_App::getWeeklyOptions();
+$repeat_weekofmonth_options = OC_Calendar_App::getWeekofMonth();
+$repeat_byyearday_options = OC_Calendar_App::getByYearDayOptions();
+$repeat_bymonth_options = OC_Calendar_App::getByMonthOptions();
+$repeat_byweekno_options = OC_Calendar_App::getByWeekNoOptions();
+$repeat_bymonthday_options = OC_Calendar_App::getByMonthDayOptions();
$tmpl = new OC_Template('calendar', 'part.editevent');
$tmpl->assign('id', $id);
@@ -66,6 +205,15 @@ $tmpl->assign('lastmodified', $lastmodified);
$tmpl->assign('calendar_options', $calendar_options);
$tmpl->assign('category_options', $category_options);
$tmpl->assign('repeat_options', $repeat_options);
+$tmpl->assign('repeat_month_options', $repeat_month_options);
+$tmpl->assign('repeat_weekly_options', $repeat_weekly_options);
+$tmpl->assign('repeat_end_options', $repeat_end_options);
+$tmpl->assign('repeat_year_options', $repeat_year_options);
+$tmpl->assign('repeat_byyearday_options', $repeat_byyearday_options);
+$tmpl->assign('repeat_bymonth_options', $repeat_bymonth_options);
+$tmpl->assign('repeat_byweekno_options', $repeat_byweekno_options);
+$tmpl->assign('repeat_bymonthday_options', $repeat_bymonthday_options);
+$tmpl->assign('repeat_weekofmonth_options', $repeat_weekofmonth_options);
$tmpl->assign('title', $summary);
$tmpl->assign('location', $location);
@@ -76,8 +224,22 @@ $tmpl->assign('startdate', $startdate);
$tmpl->assign('starttime', $starttime);
$tmpl->assign('enddate', $enddate);
$tmpl->assign('endtime', $endtime);
-$tmpl->assign('repeat', $repeat);
$tmpl->assign('description', $description);
+
+$tmpl->assign('repeat', $repeat['repeat']);
+$tmpl->assign('repeat_month', $repeat['month']);
+$tmpl->assign('repeat_weekdays', $repeat['weekdays']);
+$tmpl->assign('repeat_interval', $repeat['interval']);
+$tmpl->assign('repeat_end', $repeat['end']);
+$tmpl->assign('repeat_count', $repeat['count']);
+$tmpl->assign('repeat_weekofmonth', $repeat['weekofmonth']);
+$tmpl->assign('repeat_date', $repeat['date']);
+$tmpl->assign('repeat_year', $repeat['year']);
+$tmpl->assign('repeat_byyearday', $repeat['byyearday']);
+$tmpl->assign('repeat_bymonthday', $repeat['bymonthday']);
+$tmpl->assign('repeat_bymonth', $repeat['bymonth']);
+$tmpl->assign('repeat_byweekno', $repeat['byweekno']);
$tmpl->printpage();
+
?>
diff --git a/apps/calendar/ajax/events.php b/apps/calendar/ajax/events.php
index 1430432b8a3..998991c2fb4 100644
--- a/apps/calendar/ajax/events.php
+++ b/apps/calendar/ajax/events.php
@@ -58,7 +58,7 @@ foreach($events as $event){
}
if($return_event['allDay'] == true){
$return_event['start'] = $result->format('Y-m-d');
- $return_event['end'] = date('Y-m-d', $result->format('U') + $duration--);
+ $return_event['end'] = date('Y-m-d', $result->format('U') + --$duration);
}else{
$return_event['start'] = $result->format('Y-m-d H:i:s');
$return_event['end'] = date('Y-m-d H:i:s', $result->format('U') + $duration);
diff --git a/apps/calendar/ajax/firstdayofweek.php b/apps/calendar/ajax/firstdayofweek.php
deleted file mode 100755
index eff82cece1d..00000000000
--- a/apps/calendar/ajax/firstdayofweek.php
+++ /dev/null
@@ -1,12 +0,0 @@
-<?php
-/**
- * Copyright (c) 2011 Georg Ehrke <ownclouddev at georgswebsite dot de>
- * This file is licensed under the Affero General Public License version 3 or
- * later.
- * See the COPYING-README file.
- */
-require_once('../../../lib/base.php');
-OC_JSON::checkLoggedIn();
-$firstdayofweek = OC_Preferences::getValue( OC_User::getUser(), 'calendar', 'firstdayofweek', "1");
-OC_JSON::encodedPrint(array("firstdayofweek" => $firstdayofweek));
-?> \ No newline at end of file
diff --git a/apps/calendar/ajax/gettimezonedetection.php b/apps/calendar/ajax/gettimezonedetection.php
new file mode 100644
index 00000000000..ae58370712d
--- /dev/null
+++ b/apps/calendar/ajax/gettimezonedetection.php
@@ -0,0 +1,11 @@
+<?php
+/**
+ * Copyright (c) 2011, 2012 Georg Ehrke <ownclouddev at georgswebsite dot de>
+ * This file is licensed under the Affero General Public License version 3 or
+ * later.
+ * See the COPYING-README file.
+ */
+require_once ("../../../lib/base.php");
+OC_JSON::checkLoggedIn();
+OC_JSON::checkAppEnabled('calendar');
+OC_JSON::success(array('detection' => OC_Preferences::getValue(OC_USER::getUser(), 'calendar', 'timezonedetection'))); \ No newline at end of file
diff --git a/apps/calendar/ajax/guesstimezone.php b/apps/calendar/ajax/guesstimezone.php
index a3594498b0f..41aea26985f 100755
--- a/apps/calendar/ajax/guesstimezone.php
+++ b/apps/calendar/ajax/guesstimezone.php
@@ -1,6 +1,6 @@
<?php
/**
- * Copyright (c) 2011 Georg Ehrke <ownclouddev at georgswebsite dot de>
+ * Copyright (c) 2011, 2012 Georg Ehrke <ownclouddev at georgswebsite dot de>
* This file is licensed under the Affero General Public License version 3 or
* later.
* See the COPYING-README file.
@@ -24,11 +24,20 @@ OC_JSON::checkAppEnabled('calendar');
$l = new OC_L10N('calendar');
$lat = $_GET['lat'];
$long = $_GET['long'];
+if(OC_Preferences::getValue(OC_USER::getUser(), 'calendar', 'position') == $lat . '-' . $long && OC_Preferences::getValue(OC_USER::getUser(), 'calendar', 'timezone') != null){
+ OC_JSON::success();
+ exit;
+}
+OC_Preferences::setValue(OC_USER::getUser(), 'calendar', 'position', $lat . '-' . $long);
$geolocation = file_get_contents('http://ws.geonames.org/timezone?lat=' . $lat . '&lng=' . $long);
//Information are by Geonames (http://www.geonames.org) and licensed under the Creative Commons Attribution 3.0 License
$geoxml = simplexml_load_string($geolocation);
$geoarray = make_array_out_of_xml($geoxml);
-if(isset($geoarray['timezone']['timezoneId']) && $geoarray['timezone']['timezoneId'] != ''){
+if($geoarray['timezone']['timezoneId'] == OC_Preferences::getValue(OC_USER::getUser(), 'calendar', 'timezone')){
+ OC_JSON::success();
+ exit;
+}
+if(in_array($geoarray['timezone']['timezoneId'], DateTimeZone::listIdentifiers())){
OC_Preferences::setValue(OC_USER::getUser(), 'calendar', 'timezone', $geoarray['timezone']['timezoneId']);
$message = array('message'=> $l->t('New Timezone:') . $geoarray['timezone']['timezoneId']);
OC_JSON::success($message);
@@ -36,4 +45,4 @@ if(isset($geoarray['timezone']['timezoneId']) && $geoarray['timezone']['timezone
OC_JSON::error();
}
-?> \ No newline at end of file
+?>
diff --git a/apps/calendar/ajax/importdialog.php b/apps/calendar/ajax/importdialog.php
index 232b4ba5807..983a3d95a84 100644
--- a/apps/calendar/ajax/importdialog.php
+++ b/apps/calendar/ajax/importdialog.php
@@ -11,7 +11,7 @@ require_once('../../../lib/base.php');
$l10n = new OC_L10N('calendar');
if(!OC_USER::isLoggedIn()) {
- die("<script type=\"text/javascript\">document.location = oc_webroot;</script>");
+ die('<script type="text/javascript">document.location = oc_webroot;</script>');
}
OC_JSON::checkAppEnabled('calendar');
diff --git a/apps/calendar/ajax/newcalendar.php b/apps/calendar/ajax/newcalendar.php
index a7935c95672..af3ba4fbbea 100644
--- a/apps/calendar/ajax/newcalendar.php
+++ b/apps/calendar/ajax/newcalendar.php
@@ -8,9 +8,7 @@
require_once('../../../lib/base.php');
$l10n = new OC_L10N('calendar');
-if(!OC_USER::isLoggedIn()) {
- die("<script type=\"text/javascript\">document.location = oc_webroot;</script>");
-}
+OC_JSON::checkLoggedIn();
OC_JSON::checkAppEnabled('calendar');
$calendarcolor_options = OC_Calendar_Calendar::getCalendarColorOptions();
$calendar = array(
diff --git a/apps/calendar/ajax/newevent.php b/apps/calendar/ajax/newevent.php
index 1a696cf7780..c7c4d29943a 100644
--- a/apps/calendar/ajax/newevent.php
+++ b/apps/calendar/ajax/newevent.php
@@ -10,9 +10,7 @@ require_once('../../../lib/base.php');
$l10n = new OC_L10N('calendar');
-if(!OC_USER::isLoggedIn()) {
- die("<script type=\"text/javascript\">document.location = oc_webroot;</script>");
-}
+OC_JSON::checkLoggedIn();
OC_JSON::checkAppEnabled('calendar');
$errarr = OC_Calendar_Object::validateRequest($_POST);
diff --git a/apps/calendar/ajax/neweventform.php b/apps/calendar/ajax/neweventform.php
index e12e99219e6..3870c879b0e 100644
--- a/apps/calendar/ajax/neweventform.php
+++ b/apps/calendar/ajax/neweventform.php
@@ -34,14 +34,43 @@ $end->setTimezone(new DateTimeZone($timezone));
$calendar_options = OC_Calendar_Calendar::allCalendars(OC_User::getUser());
$category_options = OC_Calendar_App::getCategoryOptions();
$repeat_options = OC_Calendar_App::getRepeatOptions();
+$repeat_end_options = OC_Calendar_App::getEndOptions();
+$repeat_month_options = OC_Calendar_App::getMonthOptions();
+$repeat_year_options = OC_Calendar_App::getYearOptions();
+$repeat_weekly_options = OC_Calendar_App::getWeeklyOptions();
+$repeat_weekofmonth_options = OC_Calendar_App::getWeekofMonth();
+$repeat_byyearday_options = OC_Calendar_App::getByYearDayOptions();
+$repeat_bymonth_options = OC_Calendar_App::getByMonthOptions();
+$repeat_byweekno_options = OC_Calendar_App::getByWeekNoOptions();
+$repeat_bymonthday_options = OC_Calendar_App::getByMonthDayOptions();
$tmpl = new OC_Template('calendar', 'part.newevent');
$tmpl->assign('calendar_options', $calendar_options);
$tmpl->assign('category_options', $category_options);
+$tmpl->assign('repeat_options', $repeat_options);
+$tmpl->assign('repeat_month_options', $repeat_month_options);
+$tmpl->assign('repeat_weekly_options', $repeat_weekly_options);
+$tmpl->assign('repeat_end_options', $repeat_end_options);
+$tmpl->assign('repeat_year_options', $repeat_year_options);
+$tmpl->assign('repeat_byyearday_options', $repeat_byyearday_options);
+$tmpl->assign('repeat_bymonth_options', $repeat_bymonth_options);
+$tmpl->assign('repeat_byweekno_options', $repeat_byweekno_options);
+$tmpl->assign('repeat_bymonthday_options', $repeat_bymonthday_options);
+$tmpl->assign('repeat_weekofmonth_options', $repeat_weekofmonth_options);
+
$tmpl->assign('startdate', $start->format('d-m-Y'));
$tmpl->assign('starttime', $start->format('H:i'));
$tmpl->assign('enddate', $end->format('d-m-Y'));
$tmpl->assign('endtime', $end->format('H:i'));
$tmpl->assign('allday', $allday);
+$tmpl->assign('repeat', 'doesnotrepeat');
+$tmpl->assign('repeat_month', 'monthday');
+$tmpl->assign('repeat_weekdays', array());
+$tmpl->assign('repeat_interval', 1);
+$tmpl->assign('repeat_end', 'never');
+$tmpl->assign('repeat_count', '10');
+$tmpl->assign('repeat_weekofmonth', 'auto');
+$tmpl->assign('repeat_date', '');
+$tmpl->assign('repeat_year', 'bydate');
$tmpl->printpage();
?>
diff --git a/apps/calendar/ajax/setdaysofweekend.php b/apps/calendar/ajax/setdaysofweekend.php
deleted file mode 100755
index b5ef5f8573f..00000000000
--- a/apps/calendar/ajax/setdaysofweekend.php
+++ /dev/null
@@ -1,30 +0,0 @@
-<?php
-/**
- * Copyright (c) 2011 Georg Ehrke <ownclouddev at georgswebsite dot de>
- * This file is licensed under the Affero General Public License version 3 or
- * later.
- * See the COPYING-README file.
- */
-require_once('../../../lib/base.php');
-OC_JSON::checkLoggedIn();
-$weekenddays = array("Monday"=>"false", "Tuesday"=>"false", "Wednesday"=>"false", "Thursday"=>"false", "Friday"=>"false", "Saturday"=>"false", "Sunday"=>"false");
-for($i = 0;$i < count($_POST["weekend"]); $i++){
- switch ($_POST["weekend"][$i]){
- case "Monday":
- case "Tuesday":
- case "Wednesday":
- case "Thursday":
- case "Friday":
- case "Saturday":
- case "Sunday":
- break;
- default:
- OC_JSON::error();
- exit;
- }
- $weekenddays[$_POST["weekend"][$i]] = "true";
-}
-$setValue = json_encode($weekenddays);
-OC_Preferences::setValue(OC_User::getUser(), 'calendar', 'weekend', $setValue);
-OC_JSON::success();
-?>
diff --git a/apps/calendar/ajax/setduration.php b/apps/calendar/ajax/setduration.php
deleted file mode 100644
index a75c8faea42..00000000000
--- a/apps/calendar/ajax/setduration.php
+++ /dev/null
@@ -1,17 +0,0 @@
-<?php
-/**
- * Copyright (c) 2011 Georg Ehrke <ownclouddev at georgswebsite dot de>
- * This file is licensed under the Affero General Public License version 3 or
- * later.
- * See the COPYING-README file.
- */
-require_once('../../../lib/base.php');
-OC_JSON::checkLoggedIn();
-if(isset($_POST["duration"])){
- OC_Preferences::setValue(OC_User::getUser(), 'calendar', 'duration', $_POST["duration"]);
- OC_JSON::success();
-}else{
- OC_JSON::error();
-}
-?>
-
diff --git a/apps/calendar/ajax/setfirstdayofweek.php b/apps/calendar/ajax/setfirstdayofweek.php
deleted file mode 100755
index 571b95af0e3..00000000000
--- a/apps/calendar/ajax/setfirstdayofweek.php
+++ /dev/null
@@ -1,16 +0,0 @@
-<?php
-/**
- * Copyright (c) 2011 Georg Ehrke <ownclouddev at georgswebsite dot de>
- * This file is licensed under the Affero General Public License version 3 or
- * later.
- * See the COPYING-README file.
- */
-require_once('../../../lib/base.php');
-OC_JSON::checkLoggedIn();
-if(isset($_POST["firstdayofweek"])){
- OC_Preferences::setValue(OC_User::getUser(), 'calendar', 'firstdayofweek', $_POST["firstdayofweek"]);
- OC_JSON::success();
-}else{
- OC_JSON::error();
-}
-?>
diff --git a/apps/calendar/ajax/timezonedetection.php b/apps/calendar/ajax/timezonedetection.php
new file mode 100644
index 00000000000..77e4c4f6ebe
--- /dev/null
+++ b/apps/calendar/ajax/timezonedetection.php
@@ -0,0 +1,17 @@
+<?php
+/**
+ * Copyright (c) 2011, 2012 Georg Ehrke <ownclouddev at georgswebsite dot de>
+ * This file is licensed under the Affero General Public License version 3 or
+ * later.
+ * See the COPYING-README file.
+ */
+require_once ("../../../lib/base.php");
+OC_JSON::checkLoggedIn();
+OC_JSON::checkAppEnabled('calendar');
+if($_POST['timezonedetection'] == 'on'){
+ OC_Preferences::setValue(OC_USER::getUser(), 'calendar', 'timezonedetection', 'true');
+}else{
+ OC_Preferences::setValue(OC_USER::getUser(), 'calendar', 'timezonedetection', 'false');
+}
+OC_JSON::success();
+
diff --git a/apps/calendar/appinfo/app.php b/apps/calendar/appinfo/app.php
index ee990723c0c..267a74bf29a 100644
--- a/apps/calendar/appinfo/app.php
+++ b/apps/calendar/appinfo/app.php
@@ -1,26 +1,23 @@
<?php
-$l=new OC_L10N('calendar');
-OC::$CLASSPATH['OC_Calendar_App'] = 'apps/calendar/lib/app.php';
-OC::$CLASSPATH['OC_Calendar_Calendar'] = 'apps/calendar/lib/calendar.php';
-OC::$CLASSPATH['OC_Calendar_Object'] = 'apps/calendar/lib/object.php';
-OC::$CLASSPATH['OC_Calendar_Hooks'] = 'apps/calendar/lib/hooks.php';
-OC::$CLASSPATH['OC_Connector_Sabre_CalDAV'] = 'apps/calendar/lib/connector_sabre.php';
-OC_HOOK::connect('OC_User', 'post_createUser', 'OC_Calendar_Hooks', 'deleteUser');
-
-OC_Util::addScript('calendar','loader');
-
-OC_App::register( array(
- 'order' => 10,
- 'id' => 'calendar',
- 'name' => 'Calendar' ));
-
-OC_App::addNavigationEntry( array(
- 'id' => 'calendar_index',
- 'order' => 10,
- 'href' => OC_Helper::linkTo( 'calendar', 'index.php' ),
- 'icon' => OC_Helper::imagePath( 'calendar', 'icon.png' ),
- 'name' => $l->t('Calendar')));
-
-OC_App::registerPersonal('calendar', 'settings');
-
-require_once('apps/calendar/lib/search.php');
+if(version_compare(PHP_VERSION, '5.3.0', '>')){
+ $l=new OC_L10N('calendar');
+ OC::$CLASSPATH['OC_Calendar_App'] = 'apps/calendar/lib/app.php';
+ OC::$CLASSPATH['OC_Calendar_Calendar'] = 'apps/calendar/lib/calendar.php';
+ OC::$CLASSPATH['OC_Calendar_Object'] = 'apps/calendar/lib/object.php';
+ OC::$CLASSPATH['OC_Calendar_Hooks'] = 'apps/calendar/lib/hooks.php';
+ OC::$CLASSPATH['OC_Connector_Sabre_CalDAV'] = 'apps/calendar/lib/connector_sabre.php';
+ OC_HOOK::connect('OC_User', 'post_createUser', 'OC_Calendar_Hooks', 'deleteUser');
+ OC_Util::addScript('calendar','loader');
+ OC_App::register( array(
+ 'order' => 10,
+ 'id' => 'calendar',
+ 'name' => 'Calendar' ));
+ OC_App::addNavigationEntry( array(
+ 'id' => 'calendar_index',
+ 'order' => 10,
+ 'href' => OC_Helper::linkTo( 'calendar', 'index.php' ),
+ 'icon' => OC_Helper::imagePath( 'calendar', 'icon.png' ),
+ 'name' => $l->t('Calendar')));
+ OC_App::registerPersonal('calendar', 'settings');
+ require_once('apps/calendar/lib/search.php');
+}
diff --git a/apps/calendar/index.php b/apps/calendar/index.php
index 3313750d52e..e8e214c0b75 100644
--- a/apps/calendar/index.php
+++ b/apps/calendar/index.php
@@ -32,7 +32,7 @@ if(OC_Preferences::getValue(OC_USER::getUser(), 'calendar', 'currentview', 'mont
OC_Util::addScript('3rdparty/fullcalendar', 'fullcalendar');
OC_Util::addStyle('3rdparty/fullcalendar', 'fullcalendar');
-if(OC_Preferences::getValue(OC_USER::getUser(), "calendar", "timezone") == null){
+if(OC_Preferences::getValue(OC_USER::getUser(), "calendar", "timezone") == null || OC_Preferences::getValue(OC_USER::getUser(), 'calendar', 'timezonedetection') == 'true'){
OC_UTIL::addScript('calendar', 'geo');
}
OC_Util::addScript('calendar', 'calendar');
@@ -42,4 +42,7 @@ OC_Util::addStyle('', 'jquery.multiselect');
OC_App::setActiveNavigationEntry('calendar_index');
$tmpl = new OC_Template('calendar', 'calendar', 'user');
$tmpl->assign('eventSources', $eventSources);
-$tmpl->printPage(); \ No newline at end of file
+if(array_key_exists('showevent', $_GET)){
+ $tmpl->assign('showevent', $_GET['showevent']);
+}
+$tmpl->printPage();
diff --git a/apps/calendar/js/calendar.js b/apps/calendar/js/calendar.js
index 6e0a450f6a8..ae586661ccc 100644
--- a/apps/calendar/js/calendar.js
+++ b/apps/calendar/js/calendar.js
@@ -33,6 +33,19 @@ Calendar={
minWidth:'auto',
classes: 'category',
});
+ Calendar.UI.repeat('init');
+ $('#end').change(function(){
+ Calendar.UI.repeat('end');
+ });
+ $('#repeat').change(function(){
+ Calendar.UI.repeat('repeat');
+ });
+ $('#advanced_year').change(function(){
+ Calendar.UI.repeat('year');
+ });
+ $('#advanced_month').change(function(){
+ Calendar.UI.repeat('month');
+ });
$('#event').dialog({
width : 500,
close : function(event, ui) {
@@ -150,9 +163,16 @@ Calendar={
});
},
showadvancedoptions:function(){
- $("#advanced_options").css("display", "block");
+ $("#advanced_options").slideDown('slow');
$("#advanced_options_button").css("display", "none");
},
+ showadvancedoptionsforrepeating:function(){
+ if($("#advanced_options_repeating").is(":hidden")){
+ $('#advanced_options_repeating').slideDown('slow');
+ }else{
+ $('#advanced_options_repeating').slideUp('slow');
+ }
+ },
getEventPopupText:function(event){
if (event.allDay){
var timespan = $.fullCalendar.formatDates(event.start, event.end, 'ddd d MMMM[ yyyy]{ -[ddd d] MMMM yyyy}', {monthNamesShort: monthNamesShort, monthNames: monthNames, dayNames: dayNames, dayNamesShort: dayNamesShort}); //t('calendar', "ddd d MMMM[ yyyy]{ -[ddd d] MMMM yyyy}")
@@ -223,6 +243,108 @@ Calendar={
event.preventDefault();
}
},
+ repeat:function(task){
+ if(task=='init'){
+ $('#byweekno').multiselect({
+ header: false,
+ noneSelectedText: $('#advanced_byweekno').attr('title'),
+ selectedList: 2,
+ minWidth:'auto'
+ });
+ $('#weeklyoptions').multiselect({
+ header: false,
+ noneSelectedText: $('#weeklyoptions').attr('title'),
+ selectedList: 2,
+ minWidth:'auto'
+ });
+ $('input[name="bydate"]').datepicker({
+ dateFormat : 'dd-mm-yy'
+ });
+ $('#byyearday').multiselect({
+ header: false,
+ noneSelectedText: $('#byyearday').attr('title'),
+ selectedList: 2,
+ minWidth:'auto'
+ });
+ $('#bymonth').multiselect({
+ header: false,
+ noneSelectedText: $('#bymonth').attr('title'),
+ selectedList: 2,
+ minWidth:'auto'
+ });
+ $('#bymonthday').multiselect({
+ header: false,
+ noneSelectedText: $('#bymonthday').attr('title'),
+ selectedList: 2,
+ minWidth:'auto'
+ });
+ Calendar.UI.repeat('end');
+ Calendar.UI.repeat('month');
+ Calendar.UI.repeat('year');
+ Calendar.UI.repeat('repeat');
+ }
+ if(task == 'end'){
+ $('#byoccurrences').css('display', 'none');
+ $('#bydate').css('display', 'none');
+ if($('#end option:selected').val() == 'count'){
+ $('#byoccurrences').css('display', 'block');
+ }
+ if($('#end option:selected').val() == 'date'){
+ $('#bydate').css('display', 'block');
+ }
+ }
+ if(task == 'repeat'){
+ $('#advanced_month').css('display', 'none');
+ $('#advanced_weekday').css('display', 'none');
+ $('#advanced_weekofmonth').css('display', 'none');
+ $('#advanced_byyearday').css('display', 'none');
+ $('#advanced_bymonth').css('display', 'none');
+ $('#advanced_byweekno').css('display', 'none');
+ $('#advanced_year').css('display', 'none');
+ $('#advanced_bymonthday').css('display', 'none');
+ if($('#repeat option:selected').val() == 'monthly'){
+ $('#advanced_month').css('display', 'block');
+ Calendar.UI.repeat('month');
+ }
+ if($('#repeat option:selected').val() == 'weekly'){
+ $('#advanced_weekday').css('display', 'block');
+ }
+ if($('#repeat option:selected').val() == 'yearly'){
+ $('#advanced_year').css('display', 'block');
+ Calendar.UI.repeat('year');
+ }
+ if($('#repeat option:selected').val() == 'doesnotrepeat'){
+ $('#advanced_options_repeating').slideUp('slow');
+ }
+ }
+ if(task == 'month'){
+ $('#advanced_weekday').css('display', 'none');
+ $('#advanced_weekofmonth').css('display', 'none');
+ if($('#advanced_month_select option:selected').val() == 'weekday'){
+ $('#advanced_weekday').css('display', 'block');
+ $('#advanced_weekofmonth').css('display', 'block');
+ }
+ }
+ if(task == 'year'){
+ $('#advanced_weekday').css('display', 'none');
+ $('#advanced_byyearday').css('display', 'none');
+ $('#advanced_bymonth').css('display', 'none');
+ $('#advanced_byweekno').css('display', 'none');
+ $('#advanced_bymonthday').css('display', 'none');
+ if($('#advanced_year_select option:selected').val() == 'byyearday'){
+ //$('#advanced_byyearday').css('display', 'block');
+ }
+ if($('#advanced_year_select option:selected').val() == 'byweekno'){
+ $('#advanced_byweekno').css('display', 'block');
+ }
+ if($('#advanced_year_select option:selected').val() == 'bydaymonth'){
+ $('#advanced_bymonth').css('display', 'block');
+ $('#advanced_bymonthday').css('display', 'block');
+ $('#advanced_weekday').css('display', 'block');
+ }
+ }
+
+ },
Calendar:{
overview:function(){
if($('#choosecalendar_dialog').dialog('isOpen') == true){
diff --git a/apps/calendar/js/geo.js b/apps/calendar/js/geo.js
index acea17c0269..ae6a971e938 100755
--- a/apps/calendar/js/geo.js
+++ b/apps/calendar/js/geo.js
@@ -8,8 +8,9 @@ if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function(position) {
$.getJSON(OC.filePath('calendar', 'ajax', 'guesstimezone.php?lat=' + position.coords.latitude + '&long=' + position.coords.longitude + ''),
function(data){
- if (data.status == 'success'){
+ if (data.status == 'success' && typeof(data.message) != 'undefined'){
$('#notification').html(data.message);
+ $('#notification').attr('title', 'CC BY 3.0 by Geonames.org');
$('#notification').slideDown();
window.setTimeout(function(){$('#notification').slideUp();}, 5000);
}else{
diff --git a/apps/calendar/js/settings.js b/apps/calendar/js/settings.js
index 6c00be06b39..73300885565 100644
--- a/apps/calendar/js/settings.js
+++ b/apps/calendar/js/settings.js
@@ -1,63 +1,35 @@
$(document).ready(function(){
- $("#timezone").change( function(){
+ $('#timezone').change( function(){
OC.msg.startSaving('#calendar .msg')
// Serialize the data
- var post = $( "#timezone" ).serialize();
+ var post = $( '#timezone' ).serialize();
$.post( OC.filePath('calendar', 'ajax', 'settimezone.php'), post, function(data){
//OC.msg.finishedSaving('#calendar .msg', data);
});
return false;
});
- $("#timezone").chosen();
- $("#firstdayofweek").change( function(){
- var data = $("#firstdayofweek").serialize();
- $.post( OC.filePath('calendar', 'ajax', 'setfirstdayofweek.php'), data, function(data){
- if(data == "error"){
- console.log("saving first day of week failed");
- }
- });
- });
- $.getJSON(OC.filePath('calendar', 'ajax', 'firstdayofweek.php'), function(jsondata, status) {
- $("#select_" + jsondata.firstdayofweek).attr('selected',true);
- $("#firstdayofweek").chosen();
- });
- $.getJSON(OC.filePath('calendar', 'ajax', 'daysofweekend.php'), function(jsondata, status) {
- for(day in jsondata){
- if(jsondata[day] == "true"){
- $("#selectweekend_" + day).attr('selected',true);
- }
- }
- $("#weekend").chosen();
- });
- $("#timeformat").change( function(){
- var data = $("#timeformat").serialize();
+ $('#timezone').chosen();
+ $('#timeformat').change( function(){
+ var data = $('#timeformat').serialize();
$.post( OC.filePath('calendar', 'ajax', 'settimeformat.php'), data, function(data){
- if(data == "error"){
- console.log("saving timeformat failed");
+ if(data == 'error'){
+ console.log('saving timeformat failed');
}
});
});
- $.getJSON(OC.filePath('calendar', 'ajax', 'timeformat.php'), function(jsondata, status) {
- $("#" + jsondata.timeformat).attr('selected',true);
- $("#timeformat").chosen();
- });
- $("#duration").blur( function(){
- var data = $("#duration").val();
- $.post( OC.filePath('calendar', 'ajax', 'setduration.php'), {duration: data}, function(data){
- if(data == "error"){
- console.log("saving duration failed");
- }
+ $('#timezonedetection').change( function(){
+ var post = $('#timezonedetection').serialize();
+ $.post( OC.filePath('calendar', 'ajax', 'timezonedetection.php'), post, function(data){
+
});
});
- $.getJSON(OC.filePath('calendar', 'ajax', 'duration.php'), function(jsondata, status) {
- $("#duration").val(jsondata.duration);
+ $.getJSON(OC.filePath('calendar', 'ajax', 'timeformat.php'), function(jsondata, status) {
+ $('#' + jsondata.timeformat).attr('selected',true);
+ $('#timeformat').chosen();
});
- $("#weekend").change( function(){
- var data = $("#weekend").serialize();
- $.post( OC.filePath('calendar', 'ajax', 'setdaysofweekend.php'), data, function(data){
- if(data == "error"){
- console.log("saving days of weekend failed");
- }
- });
+ $.getJSON(OC.filePath('calendar', 'ajax', 'gettimezonedetection.php'), function(jsondata, status){
+ if(jsondata.detection == 'true'){
+ $('#timezonedetection').attr('checked', 'checked');
+ }
});
});
diff --git a/apps/calendar/l10n/xgettextfiles b/apps/calendar/l10n/xgettextfiles
index 27b8e457193..a8c2601045f 100644
--- a/apps/calendar/l10n/xgettextfiles
+++ b/apps/calendar/l10n/xgettextfiles
@@ -8,4 +8,5 @@
../templates/part.eventform.php
../templates/part.import.php
../templates/part.newevent.php
-../templates/settings.php \ No newline at end of file
+../templates/settings.php
+../templates/lAfix.php \ No newline at end of file
diff --git a/apps/calendar/lib/app.php b/apps/calendar/lib/app.php
index b023d531aa5..6e92cf67c5c 100644
--- a/apps/calendar/lib/app.php
+++ b/apps/calendar/lib/app.php
@@ -75,8 +75,43 @@ class OC_Calendar_App{
);
}
- public static function getRepeatOptions()
- {
- OC_Calendar_Object::getRepeatOptions(self::$l10n);
+ public static function getRepeatOptions(){
+ return OC_Calendar_Object::getRepeatOptions(self::$l10n);
+ }
+
+ public static function getEndOptions(){
+ return OC_Calendar_Object::getEndOptions(self::$l10n);
+ }
+
+ public static function getMonthOptions(){
+ return OC_Calendar_Object::getMonthOptions(self::$l10n);
+ }
+
+ public static function getWeeklyOptions(){
+ return OC_Calendar_Object::getWeeklyOptions(self::$l10n);
+ }
+
+ public static function getYearOptions(){
+ return OC_Calendar_Object::getYearOptions(self::$l10n);
+ }
+
+ public static function getByYearDayOptions(){
+ return OC_Calendar_Object::getByYearDayOptions();
+ }
+
+ public static function getByMonthOptions(){
+ return OC_Calendar_Object::getByMonthOptions(self::$l10n);
+ }
+
+ public static function getByWeekNoOptions(){
+ return OC_Calendar_Object::getByWeekNoOptions();
+ }
+
+ public static function getByMonthDayOptions(){
+ return OC_Calendar_Object::getByMonthDayOptions();
+ }
+
+ public static function getWeekofMonth(){
+ return OC_Calendar_Object::getWeekofMonth(self::$l10n);
}
}
diff --git a/apps/calendar/lib/object.php b/apps/calendar/lib/object.php
index 58fe60611ce..cbb1badf802 100644
--- a/apps/calendar/lib/object.php
+++ b/apps/calendar/lib/object.php
@@ -356,9 +356,99 @@ class OC_Calendar_Object{
'weekday' => $l10n->t('Every Weekday'),
'biweekly' => $l10n->t('Bi-Weekly'),
'monthly' => $l10n->t('Monthly'),
- 'yearly' => $l10n->t('Yearly'),
+ 'yearly' => $l10n->t('Yearly')
);
}
+
+ public static function getEndOptions($l10n)
+ {
+ return array(
+ 'never' => $l10n->t('never'),
+ 'count' => $l10n->t('by occurrences'),
+ 'date' => $l10n->t('by date')
+ );
+ }
+
+ public static function getMonthOptions($l10n)
+ {
+ return array(
+ 'monthday' => $l10n->t('by monthday'),
+ 'weekday' => $l10n->t('by weekday')
+ );
+ }
+
+ public static function getWeeklyOptions($l10n)
+ {
+ return array(
+ 'MO' => $l10n->t('Monday'),
+ 'TU' => $l10n->t('Tuesday'),
+ 'WE' => $l10n->t('Wednesday'),
+ 'TH' => $l10n->t('Thursday'),
+ 'FR' => $l10n->t('Friday'),
+ 'SA' => $l10n->t('Saturday'),
+ 'SU' => $l10n->t('Sunday')
+ );
+ }
+
+ public static function getWeekofMonth($l10n)
+ {
+ return array(
+ 'auto' => $l10n->t('events week of month'),
+ '1' => $l10n->t('first'),
+ '2' => $l10n->t('second'),
+ '3' => $l10n->t('third'),
+ '4' => $l10n->t('fourth'),
+ '5' => $l10n->t('fifth'),
+ '-1' => $l10n->t('last')
+ );
+ }
+
+ public static function getByYearDayOptions(){
+ $return = array();
+ foreach(range(1,366) as $num){
+ $return[(string) $num] = (string) $num;
+ }
+ return $return;
+ }
+
+ public static function getByMonthDayOptions(){
+ $return = array();
+ foreach(range(1,31) as $num){
+ $return[(string) $num] = (string) $num;
+ }
+ return $return;
+ }
+
+ public static function getByMonthOptions($l10n){
+ return array(
+ '1' => $l10n->t('January'),
+ '2' => $l10n->t('February'),
+ '3' => $l10n->t('March'),
+ '4' => $l10n->t('April'),
+ '5' => $l10n->t('May'),
+ '6' => $l10n->t('June'),
+ '7' => $l10n->t('July'),
+ '8' => $l10n->t('August'),
+ '9' => $l10n->t('September'),
+ '10' => $l10n->t('October'),
+ '11' => $l10n->t('November'),
+ '12' => $l10n->t('December')
+ );
+ }
+
+ public static function getYearOptions($l10n){
+ return array(
+ 'bydate' => $l10n->t('by events date'),
+ 'byyearday' => $l10n->t('by yearday(s)'),
+ 'byweekno' => $l10n->t('by weeknumber(s)'),
+ 'bydaymonth' => $l10n->t('by day and month')
+ );
+ }
+
+ public static function getByWeekNoOptions(){
+ return range(1, 52);
+ }
+
public static function validateRequest($request)
{
$errnum = 0;
@@ -397,7 +487,91 @@ class OC_Calendar_Object{
$errarr['to'] = 'true';
$errnum++;
}
- ;
+ if($request['repeat'] != 'doesnotrepeat'){
+ if(is_nan($request['interval']) && $request['interval'] != ''){
+ $errarr['interval'] = 'true';
+ $ernum++;
+ }
+ if(array_key_exists('repeat', $request) && !array_key_exists($request['repeat'], self::getRepeatOptions(OC_Calendar_App::$l10n))){
+ $errarr['repeat'] = 'true';
+ $ernum++;
+ }
+ if(array_key_exists('advanced_month_select', $request) && !array_key_exists($request['advanced_month_select'], self::getMonthOptions(OC_Calendar_App::$l10n))){
+ $errarr['advanced_month_select'] = 'true';
+ $errnum++;
+ }
+ if(array_key_exists('advanced_year_select', $request) && !array_key_exists($request['advanced_year_select'], self::getYearOptions(OC_Calendar_App::$l10n))){
+ $errarr['advanced_year_select'] = 'true';
+ $errnum++;
+ }
+ if(array_key_exists('weekofmonthoptions', $request) && !array_key_exists($request['weekofmonthoptions'], self::getWeekofMonth(OC_Calendar_App::$l10n))){
+ $errarr['weekofmonthoptions'] = 'true';
+ $errnum++;
+ }
+ if($request['end'] != 'never'){
+ if(!array_key_exists($request['end'], self::getEndOptions(OC_Calendar_App::$l10n))){
+ $errarr['end'] = 'true';
+ $errnum++;
+ }
+ if($request['end'] == 'count' && is_nan($request['byoccurrences'])){
+ $errarr['byoccurrences'] = 'true';
+ $errnum++;
+ }
+ if($request['end'] == 'date'){
+ list($bydate_day, $bydate_month, $bydate_year) = explode('-', $request['bydate']);
+ if(!checkdate($bydate_month, $bydate_day, $bydate_year)){
+ $errarr['bydate'] = 'true';
+ $errnum++;
+ }
+ }
+ }
+ if(array_key_exists('weeklyoptions', $request)){
+ foreach($request['weeklyoptions'] as $option){
+ if(!in_array($option, self::getWeeklyOptions(OC_Calendar_App::$l10n))){
+ $errarr['weeklyoptions'] = 'true';
+ $errnum++;
+ }
+ }
+ }
+ if(array_key_exists('byyearday', $request)){
+ foreach($request['byyearday'] as $option){
+ if(!array_key_exists($option, self::getByYearDayOptions())){
+ $errarr['byyearday'] = 'true';
+ $errnum++;
+ }
+ }
+ }
+ if(array_key_exists('weekofmonthoptions', $request)){
+ if(is_nan((double)$request['weekofmonthoptions'])){
+ $errarr['weekofmonthoptions'] = 'true';
+ $errnum++;
+ }
+ }
+ if(array_key_exists('bymonth', $request)){
+ foreach($request['bymonth'] as $option){
+ if(!in_array($option, self::getByMonthOptions(OC_Calendar_App::$l10n))){
+ $errarr['bymonth'] = 'true';
+ $errnum++;
+ }
+ }
+ }
+ if(array_key_exists('byweekno', $request)){
+ foreach($request['byweekno'] as $option){
+ if(!array_key_exists($option, self::getByWeekNoOptions())){
+ $errarr['byweekno'] = 'true';
+ $errnum++;
+ }
+ }
+ }
+ if(array_key_exists('bymonthday', $request)){
+ foreach($request['bymonthday'] as $option){
+ if(!array_key_exists($option, self::getByMonthDayOptions())){
+ $errarr['bymonthday'] = 'true';
+ $errnum++;
+ }
+ }
+ }
+ }
if(!$allday && self::checkTime(urldecode($request['totime']))) {
$errarr['totime'] = 'true';
$errnum++;
@@ -468,27 +642,148 @@ class OC_Calendar_Object{
$fromtime = $request['fromtime'];
$totime = $request['totime'];
}
+ $vevent = $vcalendar->VEVENT;
$description = $request["description"];
- //$repeat = $request["repeat"];
- /*switch($request["repeatfreq"]){
- case "DAILY":
- $repeatfreq = "DAILY";
- case "WEEKLY":
- $repeatfreq = "WEEKLY";
- case "WEEKDAY":
- $repeatfreq = "DAILY;BYDAY=MO,TU,WE,TH,FR"; //load weeksdayss from userconfig when weekdays are choosable
- case "":
- $repeatfreq = "";
- case "":
- $repeatfreq = "";
- case "":
- $repeatfreq = "";
- default:
- $repeat = "false";
- }*/
- $repeat = "false";
+ $repeat = $request["repeat"];
+ if($repeat != 'doesnotrepeat'){
+ $rrule = '';
+ $interval = $request['interval'];
+ $end = $request['end'];
+ $byoccurrences = $request['byoccurrences'];
+ switch($repeat){
+ case 'daily':
+ $rrule .= 'FREQ=DAILY';
+ break;
+ case 'weekly':
+ $rrule .= 'FREQ=WEEKLY';
+ if(array_key_exists('weeklyoptions', $request)){
+ $byday = '';
+ $daystrings = array_flip(self::getWeeklyOptions(OC_Calendar_App::$l10n));
+ foreach($request['weeklyoptions'] as $days){
+ if($byday == ''){
+ $byday .= $daystrings[$days];
+ }else{
+ $byday .= ',' .$daystrings[$days];
+ }
+ }
+ $rrule .= ';BYDAY=' . $byday;
+ }
+ break;
+ case 'weekday':
+ $rrule .= 'FREQ=WEEKLY';
+ $rrule .= ';BYDAY=MO,TU,WE,TH,FR';
+ break;
+ case 'biweekly':
+ $rrule .= 'FREQ=WEEKLY';
+ $interval = $interval * 2;
+ break;
+ case 'monthly':
+ $rrule .= 'FREQ=MONTHLY';
+ if($request['advanced_month_select'] == 'monthday'){
+ break;
+ }elseif($request['advanced_month_select'] == 'weekday'){
+ if($request['weekofmonthoptions'] == 'auto'){
+ list($_day, $_month, $_year) = explode('-', $from);
+ $weekofmonth = floor($_day/7);
+ }else{
+ $weekofmonth = $request['weekofmonthoptions'];
+ }
+ $days = array_flip(self::getWeeklyOptions(OC_Calendar_App::$l10n));
+ $byday = '';
+ foreach($request['weeklyoptions'] as $day){
+ if($byday == ''){
+ $byday .= $weekofmonth . $days[$day];
+ }else{
+ $byday .= ',' . $weekofmonth . $days[$day];
+ }
+ }
+ $rrule .= ';BYDAY=' . $byday;
+ }
+ break;
+ case 'yearly':
+ $rrule .= 'FREQ=YEARLY';
+ if($request['advanced_year_select'] == 'bydate'){
+
+ }elseif($request['advanced_year_select'] == 'byyearday'){
+ list($_day, $_month, $_year) = explode('-', $from);
+ $byyearday = date('z', mktime(0,0,0, $_month, $_day, $_year)) + 1;
+ if(array_key_exists('byyearday', $request)){
+ foreach($request['byyearday'] as $yearday){
+ $byyearday .= ',' . $yearday;
+ }
+ }
+ $rrule .= ';BYYEARDAY=' . $byyearday;
+ }elseif($request['advanced_year_select'] == 'byweekno'){
+ list($_day, $_month, $_year) = explode('-', $from);
+ $rrule .= ';BYDAY=' . strtoupper(substr(date('l', mktime(0,0,0, $_month, $_day, $_year)), 0, 2));
+ $byweekno = '';
+ foreach($request['byweekno'] as $weekno){
+ if($byweekno == ''){
+ $byweekno = $weekno;
+ }else{
+ $byweekno .= ',' . $weekno;
+ }
+ }
+ $rrule .= ';BYWEEKNO=' . $byweekno;
+ }elseif($request['advanced_year_select'] == 'bydaymonth'){
+ if(array_key_exists('weeklyoptions', $request)){
+ $days = array_flip(self::getWeeklyOptions(OC_Calendar_App::$l10n));
+ $byday = '';
+ foreach($request['weeklyoptions'] as $day){
+ if($byday == ''){
+ $byday .= $days[$day];
+ }else{
+ $byday .= ',' . $days[$day];
+ }
+ }
+ $rrule .= ';BYDAY=' . $byday;
+ }
+ if(array_key_exists('bymonth', $request)){
+ $monthes = array_flip(self::getByMonthOptions(OC_Calendar_App::$l10n));
+ $bymonth = '';
+ foreach($request['bymonth'] as $month){
+ if($bymonth == ''){
+ $bymonth .= $monthes[$month];
+ }else{
+ $bymonth .= ',' . $monthes[$month];
+ }
+ }
+ $rrule .= ';BYMONTH=' . $bymonth;
+
+ }
+ if(array_key_exists('bymonthday', $request)){
+ $bymonthday = '';
+ foreach($request['bymonthday'] as $monthday){
+ if($bymonthday == ''){
+ $bymonthday .= $monthday;
+ }else{
+ $bymonthday .= ',' . $monthday;
+ }
+ }
+ $rrule .= ';BYMONTHDAY=' . $bymonthday;
+
+ }
+ }
+ break;
+ default:
+ break;
+ }
+ if($interval != ''){
+ $rrule .= ';INTERVAL=' . $interval;
+ }
+ if($end == 'count'){
+ $rrule .= ';COUNT=' . $byoccurrences;
+ }
+ if($end == 'date'){
+ list($bydate_day, $bydate_month, $bydate_year) = explode('-', $request['bydate']);
+ $rrule .= ';UNTIL=' . $bydate_year . $bydate_month . $bydate_day;
+ }
+ $vevent->setString('RRULE', $rrule);
+ $repeat = "true";
+ }else{
+ $repeat = "false";
+ }
- $vevent = $vcalendar->VEVENT;
$vevent->setDateTime('LAST-MODIFIED', 'now', Sabre_VObject_Element_DateTime::UTC);
$vevent->setDateTime('DTSTAMP', 'now', Sabre_VObject_Element_DateTime::UTC);
@@ -521,4 +816,4 @@ class OC_Calendar_Object{
return $vcalendar;
}
-}
+} \ No newline at end of file
diff --git a/apps/calendar/lib/search.php b/apps/calendar/lib/search.php
index 41faf49a519..425c93c7338 100644
--- a/apps/calendar/lib/search.php
+++ b/apps/calendar/lib/search.php
@@ -12,15 +12,36 @@ class OC_Search_Provider_Calendar extends OC_Search_Provider{
}else{
$searchquery[] = $query;
}
+ $user_timezone = OC_Preferences::getValue(OC_USER::getUser(), 'calendar', 'timezone', date_default_timezone_get());
+ $l = new OC_l10n('calendar');
foreach($calendars as $calendar){
$objects = OC_Calendar_Object::all($calendar['id']);
foreach($objects as $object){
- if(substr_count(strtolower($object['summary']), strtolower($query)) > 0){//$name,$text,$link,$type
- $results[]=new OC_Search_Result($object['summary'],'','#','Cal.');
+ if(substr_count(strtolower($object['summary']), strtolower($query)) > 0){
+ $calendardata = OC_VObject::parse($object['calendardata']);
+ $vevent = $calendardata->VEVENT;
+ $dtstart = $vevent->DTSTART;
+ $dtend = OC_Calendar_Object::getDTEndFromVEvent($vevent);
+ $start_dt = $dtstart->getDateTime();
+ $start_dt->setTimezone(new DateTimeZone($user_timezone));
+ $end_dt = $dtend->getDateTime();
+ $end_dt->setTimezone(new DateTimeZone($user_timezone));
+ if ($dtstart->getDateType() == Sabre_VObject_Element_DateTime::DATE){
+ $end_dt->modify('-1 sec');
+ if($start_dt->format('d.m.Y') != $end_dt->format('d.m.Y')){
+ $info = $l->t('Date') . ': ' . $start_dt->format('d.m.Y') . ' - ' . $end_dt->format('d.m.Y');
+ }else{
+ $info = $l->t('Date') . ': ' . $start_dt->format('d.m.Y');
+ }
+ }else{
+ $info = $l->t('Date') . ': ' . $start_dt->format('d.m.y H:i') . ' - ' . $end_dt->format('d.m.y H:i');
+ }
+ $link = OC_Helper::linkTo('apps/calendar', 'index.php?showevent='.urlencode($object['id']));
+ $results[]=new OC_Search_Result($object['summary'],$info, $link,$l->t('Cal.'));//$name,$text,$link,$type
}
}
}
return $results;
}
}
-new OC_Search_Provider_Calendar(); \ No newline at end of file
+new OC_Search_Provider_Calendar();
diff --git a/apps/calendar/resettimezone.php b/apps/calendar/resettimezone.php
new file mode 100644
index 00000000000..1ef9591ae39
--- /dev/null
+++ b/apps/calendar/resettimezone.php
@@ -0,0 +1,4 @@
+<?php
+require_once ("../../lib/base.php");
+OC_Preferences::deleteKey(OC_USER::getUser(), 'calendar', 'timezone');
+?> \ No newline at end of file
diff --git a/apps/calendar/templates/calendar.php b/apps/calendar/templates/calendar.php
index 13bc8bc1bb1..50d3d70347a 100755
--- a/apps/calendar/templates/calendar.php
+++ b/apps/calendar/templates/calendar.php
@@ -18,6 +18,17 @@
var missing_field_startsbeforeends = '<?php echo $l->t('The event ends before it starts') ?>';
var missing_field_dberror = '<?php echo $l->t('There was a database fail') ?>';
var totalurl = '<?php echo OC_Helper::linkTo('apps/calendar', 'caldav.php', null, true); ?>/calendars';
+ $(document).ready(function() {
+ <?php
+ if(array_key_exists('showevent', $_)){
+ $data = OC_Calendar_App::getEventObject($_['showevent']);
+ $date = substr($data['startdate'], 0, 10);
+ list($year, $month, $day) = explode('-', $date);
+ echo '$(\'#calendar_holder\').fullCalendar(\'gotoDate\', ' . $year . ', ' . --$month . ', ' . $day . ');';
+ echo '$(\'#dialog_holder\').load(OC.filePath(\'calendar\', \'ajax\', \'editeventform.php\') + \'?id=\' + ' . $_['showevent'] . ' , Calendar.UI.startEventDialog);';
+ }
+ ?>
+ });
</script>
<div id="loading"><img src="<?php echo OC_Helper::imagePath('core', 'loading.gif'); ?>" /></div>
<div id="controls">
diff --git a/apps/calendar/templates/lAfix.php b/apps/calendar/templates/lAfix.php
new file mode 100644
index 00000000000..61025ae6dea
--- /dev/null
+++ b/apps/calendar/templates/lAfix.php
@@ -0,0 +1,39 @@
+<?php
+$l->t('Sunday');
+$l->t('Monday');
+$l->t('Tuesday');
+$l->t('Wednesday');
+$l->t('Thursday');
+$l->t('Friday');
+$l->t('Saturday');
+$l->t('Sun.');
+$l->t('Mon.');
+$l->t('Tue.');
+$l->t('Wed.');
+$l->t('Thu.');
+$l->t('Fri.');
+$l->t('Sat.');
+$l->t('January');
+$l->t('February');
+$l->t('March');
+$l->t('April');
+$l->t('May');
+$l->t('June');
+$l->t('July');
+$l->t('August');
+$l->t('September');
+$l->t('October');
+$l->t('November');
+$l->t('December');
+$l->t('Jan.');
+$l->t('Feb.');
+$l->t('Mar.');
+$l->t('Apr.');
+$l->t('May.');
+$l->t('Jun.');
+$l->t('Jul.');
+$l->t('Aug.');
+$l->t('Sep.');
+$l->t('Oct.');
+$l->t('Nov.');
+$l->t('Dec.'); \ No newline at end of file
diff --git a/apps/calendar/templates/part.eventform.php b/apps/calendar/templates/part.eventform.php
index dfa5fb8c78a..1f2073f4bc7 100644
--- a/apps/calendar/templates/part.eventform.php
+++ b/apps/calendar/templates/part.eventform.php
@@ -2,92 +2,221 @@
<tr>
<th width="75px"><?php echo $l->t("Title");?>:</th>
<td>
- <input type="text" style="width:350px;" size="100" placeholder="<?php echo $l->t("Title of the Event");?>" value="<?php echo isset($_['title']) ? $_['title'] : '' ?>" maxlength="100" name="title"/>
+ <input type="text" style="width:350px;" size="100" placeholder="<?php echo $l->t("Title of the Event");?>" value="<?php echo isset($_['title']) ? $_['title'] : '' ?>" maxlength="100" name="title"/>
</td>
</tr>
</table>
- <table>
+ <table width="100%">
<tr>
<th width="75px"><?php echo $l->t("Category");?>:</th>
<td>
- <select id="category" name="categories[]" multiple="multiple" title="<?php echo $l->t("Select category") ?>">
- <?php
- if (!isset($_['categories'])) {$_['categories'] = array();}
- echo html_select_options($_['category_options'], $_['categories'], array('combine'=>true));
- ?>
- </select></td>
+ <select id="category" name="categories[]" multiple="multiple" title="<?php echo $l->t("Select category") ?>">
+ <?php
+ if (!isset($_['categories'])) {$_['categories'] = array();}
+ echo html_select_options($_['category_options'], $_['categories'], array('combine'=>true));
+ ?>
+ </select>
+ </td>
<th width="75px">&nbsp;&nbsp;&nbsp;<?php echo $l->t("Calendar");?>:</th>
<td>
- <select style="width:140px;" name="calendar">
- <?php
- if (!isset($_['calendar'])) {$_['calendar'] = false;}
- echo html_select_options($_['calendar_options'], $_['calendar'], array('value'=>'id', 'label'=>'displayname'));
- ?>
- </select></td>
+ <select style="width:140px;" name="calendar">
+ <?php
+ if (!isset($_['calendar'])) {$_['calendar'] = false;}
+ echo html_select_options($_['calendar_options'], $_['calendar'], array('value'=>'id', 'label'=>'displayname'));
+ ?>
+ </select>
+ </td>
</tr>
</table>
<hr>
- <table>
+ <table width="100%">
<tr>
<th width="75px"></th>
<td>
- <input onclick="Calendar.UI.lockTime();" type="checkbox"<?php if($_['allday']){echo 'checked="checked"';} ?> id="allday_checkbox" name="allday">
- <label for="allday_checkbox"><?php echo $l->t("All Day Event");?></label></td>
+ <input onclick="Calendar.UI.lockTime();" type="checkbox"<?php if($_['allday']){echo 'checked="checked"';} ?> id="allday_checkbox" name="allday">
+ <label for="allday_checkbox"><?php echo $l->t("All Day Event");?></label>
+ </td>
</tr>
<tr>
-
<th width="75px"><?php echo $l->t("From");?>:</th>
<td>
- <input type="text" value="<?php echo $_['startdate'];?>" name="from" id="from">
- &nbsp;&nbsp;
- <input type="time" value="<?php echo $_['starttime'];?>" name="fromtime" id="fromtime">
- </td><!--use jquery-->
+ <input type="text" value="<?php echo $_['startdate'];?>" name="from" id="from">
+ &nbsp;&nbsp;
+ <input type="time" value="<?php echo $_['starttime'];?>" name="fromtime" id="fromtime">
+ </td>
</tr>
<tr>
<th width="75px"><?php echo $l->t("To");?>:</th>
<td>
- <input type="text" value="<?php echo $_['enddate'];?>" name="to" id="to">
- &nbsp;&nbsp;
- <input type="time" value="<?php echo $_['endtime'];?>" name="totime" id="totime">
- </td><!--use jquery-->
+ <input type="text" value="<?php echo $_['enddate'];?>" name="to" id="to">
+ &nbsp;&nbsp;
+ <input type="time" value="<?php echo $_['endtime'];?>" name="totime" id="totime">
+ </td>
</tr>
</table>
<input type="button" class="submit" value="<?php echo $l->t("Advanced options"); ?>" onclick="Calendar.UI.showadvancedoptions();" id="advanced_options_button">
<div id="advanced_options" style="display: none;">
- <!--
- <table>
- <tr>
- <th width="75px"><?php echo $l->t("Repeat");?>:</th>
- <td>
- <select name="repeat" style="width:350px;">
- <?php
- if (isset($_['repeat_options'])) {
+ <table style="width:100%">
+ <tr>
+ <th width="75px"><?php echo $l->t("Repeat");?>:</th>
+ <td>
+ <select id="repeat" name="repeat">
+ <?php
echo html_select_options($_['repeat_options'], $_['repeat']);
- }
- ?>
- </select></td>
- </tr>-->
- </table>
- <hr>
- <table><!--
- <tr>
- <th width="75px"><?php echo $l->t("Attendees");?>:</th>
- <td style="height: 50px;"></td>
- </tr>
- </table>
- <hr>-->
- <table>
- <tr>
- <th width="85px"><?php echo $l->t("Location");?>:</th>
- <td>
- <input type="text" style="width:350px;" size="100" placeholder="<?php echo $l->t("Location of the Event");?>" value="<?php echo isset($_['location']) ? $_['location'] : '' ?>" maxlength="100" name="location" />
- </td>
- </tr>
- </table>
- <table>
- <tr>
- <th width="85px" style="vertical-align: top;"><?php echo $l->t("Description");?>:</th>
- <td><textarea style="width:350px;height: 150px;" placeholder="<?php echo $l->t("Description of the Event");?>" name="description"><?php echo isset($_['description']) ? $_['description'] : '' ?></textarea></td>
- </tr>
- </table>
+ ?>
+ </select></td>
+ <td><input type="button" style="float:right;" class="submit" value="<?php echo $l->t("Advanced"); ?>" onclick="Calendar.UI.showadvancedoptionsforrepeating();" id="advanced_options_button"></td>
+ </tr>
+ </table>
+ <div id="advanced_options_repeating" style="display:none;">
+ <table style="width:100%">
+ <tr id="advanced_month" style="display:none;">
+ <th width="75px"></th>
+ <td>
+ <select id="advanced_month_select" name="advanced_month_select">
+ <?php
+ echo html_select_options($_['repeat_month_options'], $_['repeat_month']);
+ ?>
+ </select>
+ </td>
+ </tr>
+ </table>
+ <table style="width:100%">
+ <tr id="advanced_year" style="display:none;">
+ <th width="75px"></th>
+ <td>
+ <select id="advanced_year_select" name="advanced_year_select">
+ <?php
+ echo html_select_options($_['repeat_year_options'], $_['repeat_year']);
+ ?>
+ </select>
+ </td>
+ </tr>
+ </table>
+ <table style="width:100%">
+ <tr id="advanced_weekofmonth" style="display:none;">
+ <th width="75px"></th>
+ <td id="weekofmonthcheckbox">
+ <select id="weekofmonthoptions" name="weekofmonthoptions">
+ <?php
+ echo html_select_options($_['repeat_weekofmonth_options'], $_['repeat_weekofmonth']);
+ ?>
+ </select>
+ </td>
+ </tr>
+ </table>
+ <table style="width:100%">
+ <tr id="advanced_weekday" style="display:none;">
+ <th width="75px"></th>
+ <td id="weeklycheckbox">
+ <select id="weeklyoptions" name="weeklyoptions[]" multiple="multiple" title="<?php echo $l->t("Select weekdays") ?>">
+ <?php
+ if (!isset($_['weekdays'])) {$_['weekdays'] = array();}
+ echo html_select_options($_['repeat_weekly_options'], $_['repeat_weekdays'], array('combine'=>true));
+ ?>
+ </select>
+ </td>
+ </tr>
+ </table>
+ <table style="width:100%">
+ <tr id="advanced_byyearday" style="display:none;">
+ <th width="75px"></th>
+ <td id="byyeardaycheckbox">
+ <select id="byyearday" name="byyearday[]" multiple="multiple" title="<?php echo $l->t("Select days") ?>">
+ <?php
+ if (!isset($_['repeat_byyearday'])) {$_['repeat_byyearday'] = array();}
+ echo html_select_options($_['repeat_byyearday_options'], $_['repeat_byyearday'], array('combine'=>true));
+ ?>
+ </select><?php echo $l->t('and the events day of year.'); ?>
+ </td>
+ </tr>
+ </table>
+ <table style="width:100%">
+ <tr id="advanced_bymonthday" style="display:none;">
+ <th width="75px"></th>
+ <td id="bymonthdaycheckbox">
+ <select id="bymonthday" name="bymonthday[]" multiple="multiple" title="<?php echo $l->t("Select days") ?>">
+ <?php
+ if (!isset($_['repeat_bymonthday'])) {$_['repeat_bymonthday'] = array();}
+ echo html_select_options($_['repeat_bymonthday_options'], $_['repeat_bymonthday'], array('combine'=>true));
+ ?>
+ </select><?php echo $l->t('and the events day of month.'); ?>
+ </td>
+ </tr>
+ </table>
+ <table style="width:100%">
+ <tr id="advanced_bymonth" style="display:none;">
+ <th width="75px"></th>
+ <td id="bymonthcheckbox">
+ <select id="bymonth" name="bymonth[]" multiple="multiple" title="<?php echo $l->t("Select months") ?>">
+ <?php
+ if (!isset($_['repeat_bymonth'])) {$_['repeat_bymonth'] = array();}
+ echo html_select_options($_['repeat_bymonth_options'], $_['repeat_bymonth'], array('combine'=>true));
+ ?>
+ </select>
+ </td>
+ </tr>
+ </table>
+ <table style="width:100%">
+ <tr id="advanced_byweekno" style="display:none;">
+ <th width="75px"></th>
+ <td id="bymonthcheckbox">
+ <select id="byweekno" name="byweekno[]" multiple="multiple" title="<?php echo $l->t("Select weeks") ?>">
+ <?php
+ if (!isset($_['repeat_byweekno'])) {$_['repeat_byweekno'] = array();}
+ echo html_select_options($_['repeat_byweekno_options'], $_['repeat_byweekno'], array('combine'=>true));
+ ?>
+ </select><?php echo $l->t('and the events week of year.'); ?>
+ </td>
+ </tr>
+ </table>
+ <table style="width:100%">
+ <tr>
+ <th width="75px"><?php echo $l->t('Interval'); ?>:</th>
+ <td>
+ <input style="width:350px;" type="number" min="1" size="4" max="1000" value="<?php echo isset($_['repeat_interval']) ? $_['repeat_interval'] : '1'; ?>" name="interval">
+ </td>
+ </tr>
+ <tr>
+ <th width="75px"><?php echo $l->t('End'); ?>:</th>
+ <td>
+ <select id="end" name="end">
+ <?php
+ echo html_select_options($_['repeat_end_options'], $_['repeat_end']);
+ ?>
+ </select>
+ </td>
+ </tr>
+ <tr>
+ <th></th>
+ <td id="byoccurrences" style="display:none;">
+ <input type="number" min="1" max="99999" id="until_count" name="byoccurrences" value="<?php echo $_['repeat_count']; ?>"><?php echo $l->t('occurrences'); ?>
+ </td>
+ </tr>
+ <tr>
+ <th></th>
+ <td id="bydate" style="display:none;">
+ <input type="text" name="bydate" value="<?php echo $_['repeat_date']; ?>">
+ </td>
+ </tr>
+ </table>
+ </div>
+ <hr>
+ <!-- support for attendees will be added in following versions -->
+ <table>
+ <tr>
+ <th width="85px"><?php echo $l->t("Location");?>:</th>
+ <td>
+ <input type="text" style="width:350px;" size="100" placeholder="<?php echo $l->t("Location of the Event");?>" value="<?php echo isset($_['location']) ? $_['location'] : '' ?>" maxlength="100" name="location" />
+ </td>
+ </tr>
+ </table>
+ <table>
+ <tr>
+ <th width="85px" style="vertical-align: top;"><?php echo $l->t("Description");?>:</th>
+ <td>
+ <textarea style="width:350px;height: 150px;" placeholder="<?php echo $l->t("Description of the Event");?>" name="description"><?php echo isset($_['description']) ? $_['description'] : '' ?></textarea>
+ </td>
+ </tr>
+ </table>
</div>
diff --git a/apps/calendar/templates/settings.php b/apps/calendar/templates/settings.php
index 56fb55d235c..fc8e0e061d9 100644
--- a/apps/calendar/templates/settings.php
+++ b/apps/calendar/templates/settings.php
@@ -27,7 +27,7 @@
$continent=$ex[0];
echo '<option value="'.$timezone.'"'.($_['timezone'] == $timezone?' selected="selected"':'').'>'.$city.'</option>';
endforeach;?>
- </select></td></tr>
+ </select><input type="checkbox" name="timezonedetection" id="timezonedetection"><label for="timezonedetection"><?php echo $l->t('Check always for changes of the timezone'); ?></label></td></tr>
<tr><td><label for="timeformat" class="bold"><?php echo $l->t('Timeformat');?></label></td><td>
<select style="display: none;" id="timeformat" title="<?php echo "timeformat"; ?>" name="timeformat">
diff --git a/apps/contacts/ajax/addproperty.php b/apps/contacts/ajax/addproperty.php
index 98877805b46..0122cf019c7 100644
--- a/apps/contacts/ajax/addproperty.php
+++ b/apps/contacts/ajax/addproperty.php
@@ -34,13 +34,31 @@ $name = $_POST['name'];
$value = $_POST['value'];
$parameters = isset($_POST['parameters'])?$_POST['parameters']:array();
-$property = $vcard->addProperty($name, $value, $parameters);
+$property = $vcard->addProperty($name, $value); //, $parameters);
$line = count($vcard->children) - 1;
+// Apparently Sabre_VObject_Parameter doesn't do well with multiple values or I don't know how to do it. Tanghus.
+foreach ($parameters as $key=>$element) {
+ if(is_array($element) && strtoupper($key) == 'TYPE') {
+ // FIXME: Maybe this doesn't only apply for TYPE?
+ // And it probably shouldn't be done here anyways :-/
+ foreach($element as $e){
+ if($e != '' && !is_null($e)){
+ $vcard->children[$line]->parameters[] = new Sabre_VObject_Parameter($key,$e);
+ }
+ }
+ }
+}
+
OC_Contacts_VCard::edit($id,$vcard->serialize());
+$adr_types = OC_Contacts_App::getTypesOfProperty('ADR');
+$phone_types = OC_Contacts_App::getTypesOfProperty('TEL');
+
$tmpl = new OC_Template('contacts','part.property');
+$tmpl->assign('adr_types',$adr_types);
+$tmpl->assign('phone_types',$phone_types);
$tmpl->assign('property',OC_Contacts_VCard::structureProperty($property,$line));
$page = $tmpl->fetchPage();
diff --git a/apps/contacts/ajax/contacts.php b/apps/contacts/ajax/contacts.php
index b34cf414249..cf86764105f 100644
--- a/apps/contacts/ajax/contacts.php
+++ b/apps/contacts/ajax/contacts.php
@@ -6,26 +6,12 @@
* See the COPYING-README file.
*/
-function contacts_namesort($a,$b){
- return strcasecmp($a['fullname'],$b['fullname']);
-}
-
require_once('../../../lib/base.php');
OC_JSON::checkLoggedIn();
OC_JSON::checkAppEnabled('contacts');
-$addressbooks = OC_Contacts_Addressbook::active(OC_User::getUser());
-$contacts = array();
-foreach( $addressbooks as $addressbook ){
- $addressbookcontacts = OC_Contacts_VCard::all($addressbook['id']);
- foreach( $addressbookcontacts as $contact ){
- if(is_null($contact['fullname'])){
- continue;
- }
- $contacts[] = $contact;
- }
-}
-usort($contacts,'contacts_namesort');
+$ids = OC_Contacts_Addressbook::activeIds(OC_User::getUser());
+$contacts = OC_Contacts_VCard::all($ids);
$tmpl = new OC_TEMPLATE("contacts", "part.contacts");
$tmpl->assign('contacts', $contacts);
$page = $tmpl->fetchPage();
diff --git a/apps/contacts/css/styles.css b/apps/contacts/css/styles.css
index b6709c5a791..c890be85824 100644
--- a/apps/contacts/css/styles.css
+++ b/apps/contacts/css/styles.css
@@ -1,4 +1,5 @@
-#contacts li { padding-left:25px;background:url('../img/person.svg') no-repeat; }
+#contacts { padding-left:2px; padding-top: 5px; background: #fff; }
+#leftcontent a { height: 23px; display: block; margin: 0 0 0 0; padding: 0 0 0 25px; }
#chooseaddressbook {margin-right: 170px; float: right;}
#contacts_details_name { font-weight:bold;font-size:1.1em;margin-left:25%;}
#contacts_details_photo { margin:.5em 0em .5em 25%; }
diff --git a/apps/contacts/index.php b/apps/contacts/index.php
index a6af54c8789..0b705e71b5d 100644
--- a/apps/contacts/index.php
+++ b/apps/contacts/index.php
@@ -32,6 +32,9 @@ OC_Util::checkLoggedIn();
OC_Util::checkAppEnabled('contacts');
// Get active address books. This creates a default one if none exists.
+$ids = OC_Contacts_Addressbook::activeIds(OC_User::getUser());
+$contacts = OC_Contacts_VCard::all($ids);
+
$addressbooks = OC_Contacts_Addressbook::active(OC_User::getUser());
// Load the files we need
@@ -39,29 +42,21 @@ OC_App::setActiveNavigationEntry( 'contacts_index' );
// Load a specific user?
$id = isset( $_GET['id'] ) ? $_GET['id'] : null;
+$details = array();
-// sort addressbooks (use contactsort)
-usort($addressbooks,'contacts_namesort');
-
-$contacts = array();
-foreach( $addressbooks as $addressbook ){
- $addressbookcontacts = OC_Contacts_VCard::all($addressbook['id']);
- foreach( $addressbookcontacts as $contact ){
- if(is_null($contact['fullname'])){
- continue;
- }
- $contacts[] = $contact;
- }
+// FIXME: This cannot work..?
+if(is_null($id) && count($contacts) > 0) {
+ $id = $contacts[0]['id'];
}
-
-usort($contacts,'contacts_namesort');
-
-$details = array();
-if( !is_null($id)/* || count($contacts)*/){
- if(is_null($id)) $id = $contacts[0]['id'];
+if(!is_null($id)) {
$vcard = OC_Contacts_App::getContactVCard($id);
$details = OC_Contacts_VCard::structureContact($vcard);
}
+// if( !is_null($id)/* || count($contacts)*/){
+// if(is_null($id)) $id = $contacts[0]['id'];
+// $vcard = OC_Contacts_App::getContactVCard($id);
+// $details = OC_Contacts_VCard::structureContact($vcard);
+// }
// Include Style and Script
OC_Util::addScript('contacts','interface');
diff --git a/apps/contacts/js/LICENSE.jquery.inview b/apps/contacts/js/LICENSE.jquery.inview
new file mode 100644
index 00000000000..1ed340edbe5
--- /dev/null
+++ b/apps/contacts/js/LICENSE.jquery.inview
@@ -0,0 +1,41 @@
+Attribution-Non-Commercial-Share Alike 2.0 UK: England & Wales
+
+http://creativecommons.org/licenses/by-nc-sa/2.0/uk/
+
+You are free:
+
+ * to copy, distribute, display, and perform the work
+ * to make derivative works
+
+
+Under the following conditions:
+
+ * Attribution — You must give the original author credit.
+ Attribute this work:
+ Information
+ What does "Attribute this work" mean?
+ The page you came from contained embedded licensing metadata,
+ including how the creator wishes to be attributed for re-use.
+ You can use the HTML here to cite the work. Doing so will
+ also include metadata on your page so that others can find the
+ original work as well.
+
+ * Non-Commercial — You may not use this work for commercial
+ purposes.
+ * Share Alike — If you alter, transform, or build upon this
+ work, you may distribute the resulting work only under a
+ licence identical to this one.
+
+With the understanding that:
+
+ * Waiver — Any of the above conditions can be waived if you get
+ permission from the copyright holder.
+ * Other Rights — In no way are any of the following rights
+ affected by the license:
+ o Your fair dealing or fair use rights;
+ o The author's moral rights;
+ o Rights other persons may have either in the work itself
+ or in how the work is used, such as publicity or privacy rights.
+ * Notice — For any reuse or distribution, you must make clear to
+ others the licence terms of this work.
+
diff --git a/apps/contacts/js/interface.js b/apps/contacts/js/interface.js
index 3190efae3cc..b9f75bdf71a 100644
--- a/apps/contacts/js/interface.js
+++ b/apps/contacts/js/interface.js
@@ -1,3 +1,29 @@
+/**
+ * ownCloud - Addressbook
+ *
+ * @author Jakob Sack
+ * @copyright 2011 Jakob Sack mail@jakobsack.de
+ * @copyright 2011-2012 Thomas Tanghus <thomas@tanghus.net>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * TODO:
+ * If you add a contact, its thumbnail doesnt show in the list. But when you add another one it shows up, but not for the second contact added.
+ * Place a new contact in correct alphabetic order
+ */
+
+
Contacts={
UI:{
showCardDAVUrl:function(username, bookname){
@@ -113,9 +139,9 @@ Contacts={
lazyupdate:function(){
//alert('lazyupdate');
$('#contacts li').live('inview', function(){
- if (!$(this).attr('style')) {
+ if (!$(this).find('a').attr('style')) {
//alert($(this).data('id') + ' has background: ' + $(this).attr('style'));
- $(this).css('background','url(thumbnail.php?id='+$(this).data('id')+') no-repeat');
+ $(this).find('a').css('background','url(thumbnail.php?id='+$(this).data('id')+') no-repeat');
}/* else {
alert($(this).data('id') + ' has style ' + $(this).attr('style').match('url'));
}*/
@@ -301,9 +327,9 @@ $(document).ready(function(){
// bottom part of element is visible
} else {
// whole part of element is visible
- if (!$(this).attr('style')) {
+ if (!$(this).find('a').attr('style')) {
//alert($(this).data('id') + ' has background: ' + $(this).attr('style'));
- $(this).css('background','url(thumbnail.php?id='+$(this).data('id')+') no-repeat');
+ $(this).find('a').css('background','url(thumbnail.php?id='+$(this).data('id')+') no-repeat');
}/* else {
alert($(this).data('id') + ' has style ' + $(this).attr('style').match('url'));
}*/
diff --git a/apps/contacts/js/jquery.inview.txt b/apps/contacts/js/jquery.inview.txt
new file mode 100644
index 00000000000..c53dbd1d97c
--- /dev/null
+++ b/apps/contacts/js/jquery.inview.txt
@@ -0,0 +1,15 @@
+jQuery.inview is licensed Attribution-Non-Commercial-Share Alike 2.0 but the
+conditions has been waived by the author in the following tweet:
+
+https://twitter.com/#!/ChristopherBlum/status/148382899887013888
+
+Saying:
+
+Thomas Tanghus @tanghus 18 Dec. 2011
+
+@ChristopherBlum Hi. Is it OK if I use https://github.com/protonet/jquery.inview in ownCloud? Preferably under an AGPL license ;-) owncloud.org
+
+
+Christopher Blum Christopher Blum @ChristopherBlum 18 Dec. 2011
+
+@tanghus Feel free to! :)
diff --git a/apps/contacts/lib/addressbook.php b/apps/contacts/lib/addressbook.php
index 6f2f34225de..78792f5f948 100644
--- a/apps/contacts/lib/addressbook.php
+++ b/apps/contacts/lib/addressbook.php
@@ -140,6 +140,25 @@ class OC_Contacts_Addressbook{
return true;
}
+ public static function cleanArray($array, $remove_null_number = true){
+ $new_array = array();
+
+ $null_exceptions = array();
+
+ foreach ($array as $key => $value){
+ $value = trim($value);
+
+ if($remove_null_number){
+ $null_exceptions[] = '0';
+ }
+
+ if(!in_array($value, $null_exceptions) && $value != "") {
+ $new_array[] = $value;
+ }
+ }
+ return $new_array;
+ }
+
/**
* @brief Get active addressbooks for a user.
* @param integer $uid User id. If null current user will be used.
@@ -170,8 +189,21 @@ class OC_Contacts_Addressbook{
public static function active($uid){
$active = self::activeIds($uid);
$addressbooks = array();
- /** FIXME: Is there a way to prepare a statement 'WHERE id IN ([range])'?
- */
+ $ids_sql = join(',', array_fill(0, count($active), '?'));
+ $prep = 'SELECT * FROM *PREFIX*contacts_addressbooks WHERE id IN ('.$ids_sql.') ORDER BY displayname';
+ try {
+ $stmt = OC_DB::prepare( $prep );
+ $result = $stmt->execute($active);
+ } catch(Exception $e) {
+ OC_Log::write('contacts','OC_Contacts_Addressbook:active:, exception: '.$e->getMessage(),OC_Log::DEBUG);
+ OC_Log::write('contacts','OC_Contacts_Addressbook:active, ids: '.join(',', $active),OC_Log::DEBUG);
+ OC_Log::write('contacts','OC_Contacts_Addressbook::active, SQL:'.$prep,OC_Log::DEBUG);
+ }
+
+ while( $row = $result->fetchRow()){
+ $addressbooks[] = $row;
+ }
+ /*
foreach( $active as $aid ){
$stmt = OC_DB::prepare( 'SELECT * FROM *PREFIX*contacts_addressbooks WHERE id = ? ORDER BY displayname' );
$result = $stmt->execute(array($aid,));
@@ -179,7 +211,7 @@ class OC_Contacts_Addressbook{
while( $row = $result->fetchRow()){
$addressbooks[] = $row;
}
- }
+ }*/
return $addressbooks;
}
@@ -208,6 +240,7 @@ class OC_Contacts_Addressbook{
unset($openaddressbooks[array_search($id, $openaddressbooks)]);
}
}
+ $openaddressbooks = self::cleanArray($openaddressbooks, false);
sort($openaddressbooks, SORT_NUMERIC);
// FIXME: I alway end up with a ';' prepending when imploding the array..?
OC_Preferences::setValue(OC_User::getUser(),'contacts','openaddressbooks',implode(';', $openaddressbooks));
@@ -221,7 +254,7 @@ class OC_Contacts_Addressbook{
* @return boolean
*/
public static function isActive($id){
- OC_Log::write('contacts','OC_Contacts_Addressbook::isActive('.$id.'):'.in_array($id, self::activeIds()), OC_Log::DEBUG);
+ //OC_Log::write('contacts','OC_Contacts_Addressbook::isActive('.$id.'):'.in_array($id, self::activeIds()), OC_Log::DEBUG);
return in_array($id, self::activeIds());
}
diff --git a/apps/contacts/lib/vcard.php b/apps/contacts/lib/vcard.php
index 7285761fd58..beb291b481e 100644
--- a/apps/contacts/lib/vcard.php
+++ b/apps/contacts/lib/vcard.php
@@ -47,9 +47,21 @@ class OC_Contacts_VCard{
* ['carddata']
*/
public static function all($id){
- $stmt = OC_DB::prepare( 'SELECT * FROM *PREFIX*contacts_cards WHERE addressbookid = ? ORDER BY fullname' );
- $result = $stmt->execute(array($id));
-
+ if(is_array($id)) {
+ $id_sql = join(',', array_fill(0, count($id), '?'));
+ $prep = 'SELECT * FROM *PREFIX*contacts_cards WHERE addressbookid IN ('.$id_sql.') ORDER BY fullname';
+ try {
+ $stmt = OC_DB::prepare( $prep );
+ $result = $stmt->execute($id);
+ } catch(Exception $e) {
+ OC_Log::write('contacts','OC_Contacts_VCard:all:, exception: '.$e->getMessage(),OC_Log::DEBUG);
+ OC_Log::write('contacts','OC_Contacts_VCard:all, ids: '.join(',', $id),OC_Log::DEBUG);
+ OC_Log::write('contacts','SQL:'.$prep,OC_Log::DEBUG);
+ }
+ } else {
+ $stmt = OC_DB::prepare( 'SELECT * FROM *PREFIX*contacts_cards WHERE addressbookid = ? ORDER BY fullname' );
+ $result = $stmt->execute(array($id));
+ }
$cards = array();
while( $row = $result->fetchRow()){
$cards[] = $row;
diff --git a/apps/contacts/templates/part.property.php b/apps/contacts/templates/part.property.php
index d930a9ca99d..e4010397500 100644
--- a/apps/contacts/templates/part.property.php
+++ b/apps/contacts/templates/part.property.php
@@ -25,15 +25,14 @@
<?php echo $_['property']['value']; ?>
<?php if(isset($_['property']['parameters']['TYPE']) && !empty($_['property']['parameters']['TYPE'])): ?>
<?php
- $types = array();
- foreach($_['property']['parameters']['TYPE'] as $type):
+ foreach($_['property']['parameters']['TYPE'] as $type) {
if (isset($_['phone_types'][strtoupper($type)])){
$types[]=$_['phone_types'][strtoupper($type)];
}
else{
$types[]=$l->t(ucwords(strtolower($type)));
}
- endforeach;
+ }
$label = join(' ', $types);
?>
(<?php echo $label; ?>)
diff --git a/apps/contacts/templates/part.setpropertyform.php b/apps/contacts/templates/part.setpropertyform.php
index 8635d7db1ce..3e0b8d49b52 100644
--- a/apps/contacts/templates/part.setpropertyform.php
+++ b/apps/contacts/templates/part.setpropertyform.php
@@ -45,7 +45,7 @@
<p class="contacts_property_name"><label for="tel"><?php echo $l->t('Phone'); ?></label></p>
<p class="contacts_property_data"><input id="tel" type="phone" name="value" value="<?php echo $_['property']['value'] ?>">
<select id="tel_type<?php echo $_['property']['checksum'] ?>" name="parameters[TYPE][]" multiple="multiple" data-placeholder="<?php echo $l->t('Type') ?>">
- <?php echo html_select_options($_['phone_types'], isset($_['property']['parameters']['TYPE'])?$_['property']['parameters']['TYPE']:'') ?>
+ <?php echo html_select_options($_['phone_types'], isset($_['property']['parameters']['TYPE'])?$_['property']['parameters']['TYPE']:array()) ?>
</select></p>
<?php elseif($_['property']['name']=='EMAIL'): ?>
<p class="contacts_property_name"><label for="email"><?php echo $l->t('Email'); ?></label></p>
diff --git a/apps/contacts/thumbnail.php b/apps/contacts/thumbnail.php
index bf0a6e96a5d..622718d65c6 100644
--- a/apps/contacts/thumbnail.php
+++ b/apps/contacts/thumbnail.php
@@ -2,8 +2,8 @@
/**
* ownCloud - Addressbook
*
- * @author Jakob Sack
- * @copyright 2011 Jakob Sack mail@jakobsack.de
+ * @author Thomas Tanghus
+ * @copyright 2011-2012 Thomas Tanghus <thomas@tanghus.net>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
@@ -26,7 +26,7 @@ OC_Util::checkLoggedIn();
OC_Util::checkAppEnabled('contacts');
if(!function_exists('imagecreatefromjpeg')) {
- OC_Log::write('contacts','GD module not installed',OC_Log::ERROR);
+ OC_Log::write('contacts','thumbnail.php. GD module not installed',OC_Log::DEBUG);
header('Content-Type: image/png');
// TODO: Check if it works to read the file and echo the content.
return 'img/person.png';
@@ -46,13 +46,16 @@ $l10n = new OC_L10N('contacts');
$card = OC_Contacts_VCard::find( $id );
if( $card === false ){
- echo $l10n->t('Contact could not be found.');
+ OC_Log::write('contacts','thumbnail.php. Contact could not be found.',OC_Log::ERROR);
+ //echo $l10n->t('Contact could not be found.');
exit();
}
+// FIXME: Is this check necessary? It just takes up CPU time.
$addressbook = OC_Contacts_Addressbook::find( $card['addressbookid'] );
if( $addressbook === false || $addressbook['userid'] != OC_USER::getUser()){
- echo $l10n->t('This is not your contact.'); // This is a weird error, why would it come up? (Better feedback for users?)
+ OC_Log::write('contacts','thumbnail.php. Wrong contact/addressbook - WTF?',OC_Log::ERROR);
+ //echo $l10n->t('This is not your contact.'); // This is a weird error, why would it come up? (Better feedback for users?)
exit();
}
@@ -60,17 +63,14 @@ $content = OC_VObject::parse($card['carddata']);
// invalid vcard
if( is_null($content)){
- echo $l10n->t('This card is not RFC compatible.');
+ OC_Log::write('contacts','thumbnail.php. The VCard for ID '.$id.' is not RFC compatible',OC_Log::ERROR);
+ getStandardImage();
exit();
}
-// define the width and height for the thumbnail
-// note that theese dimmensions are considered the maximum dimmension and are not fixed,
-// because we have to keep the image ratio intact or it will be deformed
-$thumbnail_width = 23;
-$thumbnail_height = 23;
+$thumbnail_size = 23;
-// Photo :-)
+// Finf the photo from VCard.
foreach($content->children as $child){
if($child->name == 'PHOTO'){
foreach($child->parameters as $parameter){
@@ -78,73 +78,31 @@ foreach($content->children as $child){
$mime = $parameter->value;
}
}
- $data = base64_decode($child->value);
- $src_img = imagecreatefromstring($data);
- if ($src_img !== false) {
- //gets the dimmensions of the image
- $width_orig=imageSX($src_img);
- $height_orig=imageSY($src_img);
- $ratio_orig = $width_orig/$height_orig;
-
- if ($thumbnail_width/$thumbnail_height > $ratio_orig) {
- $new_height = $thumbnail_width/$ratio_orig;
- $new_width = $thumbnail_width;
- } else {
- $new_width = $thumbnail_height*$ratio_orig;
- $new_height = $thumbnail_height;
- }
-
- $x_mid = $new_width/2; //horizontal middle
- $y_mid = $new_height/2; //vertical middle
-
- $process = imagecreatetruecolor(round($new_width), round($new_height));
- if ($process == false) {
- getStandardImage();
- //echo 'Error creating process image: '.$new_width.'x'.$new_height;
- OC_Log::write('contacts','Error creating process image for '.$id.' '.$new_width.'x'.$new_height,OC_Log::ERROR);
- imagedestroy($process);
- imagedestroy($src_img);
- exit();
- }
-
- imagecopyresampled($process, $src_img, 0, 0, 0, 0, $new_width, $new_height, $width_orig, $height_orig);
- if ($process == false) {
- getStandardImage();
- //echo 'Error resampling process image: '.$new_width.'x'.$new_height;
- OC_Log::write('contacts','Error resampling process image for '.$id.' '.$new_width.'x'.$new_height,OC_Log::ERROR);
- imagedestroy($process);
- imagedestroy($src_img);
- exit();
- }
- $thumb = imagecreatetruecolor($thumbnail_width, $thumbnail_height);
- if ($process == false) {
+ $image = new OC_Image();
+ if($image->loadFromBase64($child->value)) {
+ if($image->centerCrop()) {
+ if($image->resize($thumbnail_size)) {
+ if(!$image()) {
+ OC_Log::write('contacts','thumbnail.php. Couldn\'t display thumbnail for ID '.$id,OC_Log::ERROR);
+ getStandardImage();
+ exit();
+ }
+ } else {
+ OC_Log::write('contacts','thumbnail.php. Couldn\'t resize thumbnail for ID '.$id,OC_Log::ERROR);
+ getStandardImage();
+ exit();
+ }
+ }else{
+ OC_Log::write('contacts','thumbnail.php. Couldn\'t crop thumbnail for ID '.$id,OC_Log::ERROR);
getStandardImage();
- //echo 'Error creating thumb image: '.$thumbnail_width.'x'.$thumbnail_height;
- OC_Log::write('contacts','Error creating thumb image for '.$id.' '.$thumbnail_width.'x'.$thumbnail_height,OC_Log::ERROR);
- imagedestroy($process);
- imagedestroy($src_img);
exit();
}
- imagecopyresampled($thumb, $process, 0, 0, ($x_mid-($thumbnail_width/2)), ($y_mid-($thumbnail_height/2)), $thumbnail_width, $thumbnail_height, $thumbnail_width, $thumbnail_height);
- if ($thumb !== false) {
- header('Content-Type: image/png');
- imagepng($thumb);
- } else {
- getStandardImage();
- OC_Log::write('contacts','Error resampling thumb image for '.$id.' '.$thumbnail_width.'x'.$thumbnail_height,OC_Log::ERROR);
- //echo 'An error occurred resampling thumb.';
- }
- imagedestroy($thumb);
- imagedestroy($process);
- imagedestroy($src_img);
- }
- else {
+ } else {
+ OC_Log::write('contacts','thumbnail.php. Couldn\'t load image string for ID '.$id,OC_Log::ERROR);
getStandardImage();
+ exit();
}
exit();
}
}
getStandardImage();
-
-// Not found :-(
-//echo $l10n->t('This card does not contain a photo.');
diff --git a/apps/files_sharing/sharedstorage.php b/apps/files_sharing/sharedstorage.php
index d78e273bf38..b0eaeecf723 100644
--- a/apps/files_sharing/sharedstorage.php
+++ b/apps/files_sharing/sharedstorage.php
@@ -79,20 +79,16 @@ class OC_Filestorage_Shared extends OC_Filestorage {
if ($path == "" || $path == "/") {
$path = $this->datadir.$path;
$sharedItems = OC_Share::getItemsInFolder($path);
- if (empty($sharedItems)) {
- return false;
- } else {
- global $FAKEDIRS;
- $files = array();
- foreach ($sharedItems as $item) {
- // If item is in the root of the shared storage provider and the item exists add it to the fakedirs
- if (dirname($item['target'])."/" == $path && $this->file_exists(basename($item['target']))) {
- $files[] = basename($item['target']);
- }
+ global $FAKEDIRS;
+ $files = array();
+ foreach ($sharedItems as $item) {
+ // If item is in the root of the shared storage provider and the item exists add it to the fakedirs
+ if (dirname($item['target'])."/" == $path && $this->file_exists(basename($item['target']))) {
+ $files[] = basename($item['target']);
}
- $FAKEDIRS['shared'] = $files;
- return opendir('fakedir://shared');
}
+ $FAKEDIRS['shared'] = $files;
+ return opendir('fakedir://shared');
} else {
$source = $this->getSource($path);
if ($source) {
diff --git a/apps/gallery/ajax/cover.php b/apps/gallery/ajax/cover.php
index d83f4daaa52..181a919375d 100644
--- a/apps/gallery/ajax/cover.php
+++ b/apps/gallery/ajax/cover.php
@@ -1,4 +1,26 @@
<?php
+
+/**
+* ownCloud - gallery application
+*
+* @author Bartek Przybylski
+* @copyright 2012 Bartek Przybylski bart.p.pl@gmail.com
+*
+* This library is free software; you can redistribute it and/or
+* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
+* License as published by the Free Software Foundation; either
+* version 3 of the License, or any later version.
+*
+* This library is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this library. If not, see <http://www.gnu.org/licenses/>.
+*
+*/
+
require_once('../../../lib/base.php');
OC_JSON::checkLoggedIn();
OC_JSON::checkAppEnabled('gallery');
diff --git a/apps/gallery/ajax/createAlbum.php b/apps/gallery/ajax/createAlbum.php
index 9413b54718a..152f5834bcb 100644
--- a/apps/gallery/ajax/createAlbum.php
+++ b/apps/gallery/ajax/createAlbum.php
@@ -1,4 +1,26 @@
<?php
+
+/**
+* ownCloud - gallery application
+*
+* @author Bartek Przybylski
+* @copyright 2012 Bartek Przybylski bart.p.pl@gmail.com
+*
+* This library is free software; you can redistribute it and/or
+* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
+* License as published by the Free Software Foundation; either
+* version 3 of the License, or any later version.
+*
+* This library is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this library. If not, see <http://www.gnu.org/licenses/>.
+*
+*/
+
require_once('../../../lib/base.php');
OC_JSON::checkLoggedIn();
OC_JSON::checkAppEnabled('gallery');
diff --git a/apps/gallery/ajax/galleryOp.php b/apps/gallery/ajax/galleryOp.php
index cd7cab202b1..3d1ed1f33cb 100644
--- a/apps/gallery/ajax/galleryOp.php
+++ b/apps/gallery/ajax/galleryOp.php
@@ -1,6 +1,28 @@
<?
+
+/**
+* ownCloud - gallery application
+*
+* @author Bartek Przybylski
+* @copyright 2012 Bartek Przybylski bart.p.pl@gmail.com
+*
+* This library is free software; you can redistribute it and/or
+* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
+* License as published by the Free Software Foundation; either
+* version 3 of the License, or any later version.
+*
+* This library is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this library. If not, see <http://www.gnu.org/licenses/>.
+*
+*/
+
require_once('../../../lib/base.php');
-require_once('../lib/album.php');
+require_once(OC::$CLASSPATH['OC_Gallery_Album']);
OC_JSON::checkLoggedIn();
OC_JSON::checkAppEnabled('gallery');
@@ -26,4 +48,4 @@ if ($_GET['operation']) {
OC_JSON::error(array('cause' => "Unknown operation"));
}
}
-?> \ No newline at end of file
+?>
diff --git a/apps/gallery/ajax/getAlbums.php b/apps/gallery/ajax/getAlbums.php
index e4736076fed..9e9c6ef496c 100644
--- a/apps/gallery/ajax/getAlbums.php
+++ b/apps/gallery/ajax/getAlbums.php
@@ -1,4 +1,26 @@
<?php
+
+/**
+* ownCloud - gallery application
+*
+* @author Bartek Przybylski
+* @copyright 2012 Bartek Przybylski bart.p.pl@gmail.com
+*
+* This library is free software; you can redistribute it and/or
+* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
+* License as published by the Free Software Foundation; either
+* version 3 of the License, or any later version.
+*
+* This library is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this library. If not, see <http://www.gnu.org/licenses/>.
+*
+*/
+
require_once('../../../lib/base.php');
OC_JSON::checkLoggedIn();
OC_JSON::checkAppEnabled('gallery');
diff --git a/apps/gallery/ajax/getCovers.php b/apps/gallery/ajax/getCovers.php
index db7c8e9fcde..4db73d0fbf3 100644
--- a/apps/gallery/ajax/getCovers.php
+++ b/apps/gallery/ajax/getCovers.php
@@ -1,4 +1,26 @@
<?php
+
+/**
+* ownCloud - gallery application
+*
+* @author Bartek Przybylski
+* @copyright 2012 Bartek Przybylski bart.p.pl@gmail.com
+*
+* This library is free software; you can redistribute it and/or
+* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
+* License as published by the Free Software Foundation; either
+* version 3 of the License, or any later version.
+*
+* This library is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this library. If not, see <http://www.gnu.org/licenses/>.
+*
+*/
+
require_once('../../../lib/base.php');
OC_JSON::checkLoggedIn();
OC_JSON::checkAppEnabled('gallery');
diff --git a/apps/gallery/ajax/scanForAlbums.php b/apps/gallery/ajax/scanForAlbums.php
index f603cbb4971..b8ed639d9dc 100644
--- a/apps/gallery/ajax/scanForAlbums.php
+++ b/apps/gallery/ajax/scanForAlbums.php
@@ -1,10 +1,31 @@
<?php
+/**
+* ownCloud - gallery application
+*
+* @author Bartek Przybylski
+* @copyright 2012 Bartek Przybylski bart.p.pl@gmail.com
+*
+* This library is free software; you can redistribute it and/or
+* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
+* License as published by the Free Software Foundation; either
+* version 3 of the License, or any later version.
+*
+* This library is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this library. If not, see <http://www.gnu.org/licenses/>.
+*
+*/
+
require_once('../../../lib/base.php');
OC_JSON::checkLoggedIn();
OC_JSON::checkAppEnabled('gallery');
OC_Gallery_Scanner::cleanUp();
-OC_JSON::success(array('albums' => OC_Gallery_Scanner::scan('')));
+OC_JSON::success(array('albums' => OC_Gallery_Scanner::scan('/')));
?>
diff --git a/apps/gallery/ajax/thumbnail.php b/apps/gallery/ajax/thumbnail.php
index d937691fa03..6d25c7a2536 100644
--- a/apps/gallery/ajax/thumbnail.php
+++ b/apps/gallery/ajax/thumbnail.php
@@ -1,4 +1,26 @@
<?php
+
+/**
+* ownCloud - gallery application
+*
+* @author Bartek Przybylski
+* @copyright 2012 Bartek Przybylski bart.p.pl@gmail.com
+*
+* This library is free software; you can redistribute it and/or
+* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
+* License as published by the Free Software Foundation; either
+* version 3 of the License, or any later version.
+*
+* This library is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this library. If not, see <http://www.gnu.org/licenses/>.
+*
+*/
+
require_once('../../../lib/base.php');
OC_JSON::checkLoggedIn();
OC_JSON::checkAppEnabled('gallery');
diff --git a/apps/gallery/appinfo/app.php b/apps/gallery/appinfo/app.php
index 2b1ab857afc..9c665fd3500 100644
--- a/apps/gallery/appinfo/app.php
+++ b/apps/gallery/appinfo/app.php
@@ -1,7 +1,30 @@
<?php
+
+/**
+* ownCloud - gallery application
+*
+* @author Bartek Przybylski
+* @copyright 2012 Bartek Przybylski bart.p.pl@gmail.com
+*
+* This library is free software; you can redistribute it and/or
+* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
+* License as published by the Free Software Foundation; either
+* version 3 of the License, or any later version.
+*
+* This library is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this library. If not, see <http://www.gnu.org/licenses/>.
+*
+*/
+
OC::$CLASSPATH['OC_Gallery_Album'] = 'apps/gallery/lib/album.php';
OC::$CLASSPATH['OC_Gallery_Photo'] = 'apps/gallery/lib/photo.php';
OC::$CLASSPATH['OC_Gallery_Scanner'] = 'apps/gallery/lib/scanner.php';
+OC::$CLASSPATH['OC_Gallery_Hooks_Handlers'] = 'apps/gallery/lib/hooks_handlers.php';
OC_App::register(array(
'order' => 20,
@@ -28,4 +51,6 @@ OC_App::addNavigationEntry( array(
}
new OC_GallerySearchProvider();
+
+require_once('apps/gallery/lib/hooks_handlers.php');
?>
diff --git a/apps/gallery/appinfo/database.xml b/apps/gallery/appinfo/database.xml
index fd55b3a6fb4..db88e4c1b5a 100644
--- a/apps/gallery/appinfo/database.xml
+++ b/apps/gallery/appinfo/database.xml
@@ -27,6 +27,12 @@
<notnull>true</notnull>
<length>100</length>
</field>
+ <field>
+ <name>album_path</name>
+ <type>text</type>
+ <notnull>true</notnull>
+ <length>100</length>
+ </field>
</declaration>
</table>
<table>
diff --git a/apps/gallery/appinfo/info.xml b/apps/gallery/appinfo/info.xml
index 054ddb6f139..c275f39bb25 100644
--- a/apps/gallery/appinfo/info.xml
+++ b/apps/gallery/appinfo/info.xml
@@ -2,9 +2,10 @@
<info>
<id>gallery</id>
<name>Gallery</name>
- <version>0.1</version>
+ <version>0.2</version>
<licence>AGPL</licence>
- <author>Bartosz Przybylski</author>
+ <author>Bartek Przybylski</author>
<require>2</require>
- <description></description>
-</info> \ No newline at end of file
+ <description>Gallery application for ownCloud</description>
+ <default_enable/>
+</info>
diff --git a/apps/gallery/css/styles.css b/apps/gallery/css/styles.css
index 53c3c0901d9..cc343ba0d08 100644
--- a/apps/gallery/css/styles.css
+++ b/apps/gallery/css/styles.css
@@ -1,60 +1,11 @@
-div#gallery_list {
- margin: 90pt 20pt;
-}
-div#gallery_list.leftcontent {
- padding-top: 15px;
- margin: 0;
- text-align: center;
-}
+div#gallery_list { margin: 90pt 20pt; }
+div#gallery_list.leftcontent { padding-top: 15px; margin: 0; text-align: center; }
+div#gallery_album_box { width: 200px; text-align: center; border: 0; display: inline-block; margin: 5pt; vertical-align: top; padding: 10px; border: solid 1px black; position: relative; overflow: hidden; color: #999; }
+div#gallery_album_box:hover { color: black; }
+.leftcontent div#gallery_album_box { margin: 5px; }
+div#gallery_album_box h1 { font-size: 12pt; font-family: Verdana; }
+div#gallery_album_cover { width: 199px; height: 199px; border: solid 1pt #999; padding: 0; }
+div#gallery_control_overlay { border: 0; position:absolute; right: 10pt; background-color: #333; opacity: 0.5; visibility:hidden; padding: 0 5pt; }
+div#gallery_control_overlay a { color:white; }
+#gallery_images { padding:10px 5px; }
-div#gallery_album_box {
- width: 200px;
- text-align: center;
- border: 0;
- display: inline-block;
- margin: 5pt;
- vertical-align: top;
- padding: 10px;
- border: solid 1px black;
- position: relative;
- overflow: hidden;
- color: #999;
-}
-
-div#gallery_album_box:hover {
- color: black;
-}
-
-.leftcontent div#gallery_album_box {
- margin: 5px;
-}
-
-div#gallery_album_box h1 {
- font-size: 12pt;
- font-family: Verdana;
-}
-
-div#gallery_album_cover {
- width: 199px;
- height: 199px;
- border: solid 1pt #999;
- padding: 0;
-}
-
-div#gallery_control_overlay {
- border: 0;
- position:absolute;
- right: 10pt;
- background-color: #333;
- opacity: 0.5;
- visibility:hidden;
- padding: 0 5pt;
-}
-
-div#gallery_control_overlay a {
- color:white;
-}
-
-#gallery_images {
-padding:10px 5px;
-}
diff --git a/apps/gallery/index.php b/apps/gallery/index.php
index 0cd795bac01..822a5b8e143 100644
--- a/apps/gallery/index.php
+++ b/apps/gallery/index.php
@@ -1,4 +1,26 @@
<?php
+
+/**
+* ownCloud - gallery application
+*
+* @author Bartek Przybylski
+* @copyright 2012 Bartek Przybylski bart.p.pl@gmail.com
+*
+* This library is free software; you can redistribute it and/or
+* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
+* License as published by the Free Software Foundation; either
+* version 3 of the License, or any later version.
+*
+* This library is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this library. If not, see <http://www.gnu.org/licenses/>.
+*
+*/
+
require_once('../../lib/base.php');
OC_Util::checkLoggedIn();
diff --git a/apps/gallery/js/album_cover.js b/apps/gallery/js/album_cover.js
index 619aa391c56..f6cb2da3103 100644
--- a/apps/gallery/js/album_cover.js
+++ b/apps/gallery/js/album_cover.js
@@ -31,7 +31,11 @@ function createNewAlbum() {
}
function scanForAlbums() {
+ $("#notification").fadeIn();
+ $("#notification").slideDown();
$.getJSON('ajax/scanForAlbums.php', function(r) {
+ $("#notification").fadeOut();
+ $("#notification").slideUp();
if (r.status == 'success') {
window.location.reload(true);
} else {
diff --git a/apps/gallery/lib/album.php b/apps/gallery/lib/album.php
index 0999429c5d5..a94eff3acd7 100644
--- a/apps/gallery/lib/album.php
+++ b/apps/gallery/lib/album.php
@@ -1,9 +1,30 @@
<?php
+/**
+* ownCloud - gallery application
+*
+* @author Bartek Przybylski
+* @copyright 2012 Bartek Przybylski bart.p.pl@gmail.com
+*
+* This library is free software; you can redistribute it and/or
+* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
+* License as published by the Free Software Foundation; either
+* version 3 of the License, or any later version.
+*
+* This library is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this library. If not, see <http://www.gnu.org/licenses/>.
+*
+*/
+
class OC_Gallery_Album {
- public static function create($owner, $name){
- $stmt = OC_DB::prepare('INSERT INTO *PREFIX*gallery_albums (uid_owner, album_name) VALUES (?, ?)');
- $stmt->execute(array($owner, $name));
+ public static function create($owner, $name, $path){
+ $stmt = OC_DB::prepare('INSERT INTO *PREFIX*gallery_albums (uid_owner, album_name, album_path) VALUES (?, ?, ?)');
+ $stmt->execute(array($owner, $name, $path));
}
public static function rename($oldname, $newname, $owner) {
@@ -22,14 +43,21 @@ class OC_Gallery_Album {
return $stmt->execute($args);
}
- public static function find($owner, $name=null){
+ public static function find($owner, $name=null, $path=null){
$sql = 'SELECT * FROM *PREFIX*gallery_albums WHERE uid_owner = ?';
$args = array($owner);
if (!is_null($name)){
$sql .= ' AND album_name = ?';
$args[] = $name;
- }
+ }
+ if (!is_null($path)){
+ $sql .= ' AND album_path = ?';
+ $args[] = $path;
+ }
$stmt = OC_DB::prepare($sql);
return $stmt->execute($args);
}
+
}
+
+?>
diff --git a/apps/gallery/lib/hooks_handlers.php b/apps/gallery/lib/hooks_handlers.php
new file mode 100644
index 00000000000..65f3faaeeaf
--- /dev/null
+++ b/apps/gallery/lib/hooks_handlers.php
@@ -0,0 +1,118 @@
+<?php
+
+/**
+* ownCloud - gallery application
+*
+* @author Bartek Przybylski
+* @copyright 2012 Bartek Przybylski bart.p.pl@gmail.com
+*
+* This library is free software; you can redistribute it and/or
+* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
+* License as published by the Free Software Foundation; either
+* version 3 of the License, or any later version.
+*
+* This library is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this library. If not, see <http://www.gnu.org/licenses/>.
+*
+*/
+
+OC_Hook::connect("OC_Filesystem", "post_write", "OC_Gallery_Hooks_Handlers", "addPhotoFromPath");
+OC_Hook::connect("OC_Filesystem", "delete", "OC_Gallery_Hooks_Handlers", "removePhoto");
+OC_Hook::connect("OC_Filesystem", "post_rename", "OC_Gallery_Hooks_Handlers", "renamePhoto");
+
+require_once(OC::$CLASSPATH['OC_Gallery_Album']);
+require_once(OC::$CLASSPATH['OC_Gallery_Photo']);
+
+class OC_Gallery_Hooks_Handlers {
+ private static $APP_TAG = "Gallery";
+
+ private static function isPhoto($filename) {
+ OC_Log::write(self::$APP_TAG, "Checking file ".$filename." with mimetype ".OC_Filesystem::getMimeType($filename), OC_Log::DEBUG);
+ if (substr(OC_Filesystem::getMimeType($filename), 0, 6) == "image/")
+ return 1;
+ return 0;
+ }
+
+ private static function createAlbum($path) {
+ $new_album_name = trim(str_replace('/', '.', $path), '.');
+ if ($new_album_name == '')
+ $new_album_name = 'main';
+
+ OC_Log::write(self::$APP_TAG, 'Creating new album '.$new_album_name, OC_Log::DEBUG);
+ OC_Gallery_Album::create(OC_User::getUser(), $new_album_name, $path);
+
+ return OC_Gallery_Album::find(OC_User::getUser(), null, $path);
+ }
+
+ public static function addPhotoFromPath($params) {
+ if (!self::isPhoto($params['path'])) return;
+ $fullpath = $params['path'];
+ OC_Log::write(self::$APP_TAG, 'Adding file with path '. $fullpath, OC_Log::DEBUG);
+ $path = substr($fullpath, 0, strrpos($fullpath, '/'));
+ if ($path == '') $path = '/';
+ $album = OC_Gallery_Album::find(OC_User::getUser(), null, $path);
+
+ if ($album->numRows() == 0) {
+ $album = self::createAlbum($path);
+ }
+ $album = $album->fetchRow();
+ $albumId = $album['album_id'];
+ $photo = OC_Gallery_Photo::find($albumId, $fullpath);
+ if ($photo->numRows() == 0) { // don't duplicate photo entries
+ OC_Log::write(self::$APP_TAG, 'Adding new photo to album', OC_Log::DEBUG);
+ OC_Gallery_Photo::create($albumId, $fullpath);
+ }
+
+ }
+
+ public static function removePhoto($params) {
+ $path = $params['path'];
+ if (!self::isPhoto($path)) return;
+ OC_Gallery_Photo::removeByPath($path);
+ }
+
+ public static function renamePhoto($params) {
+ $olddir = substr($params['oldpath'], 0, strrpos($params['oldpath'], '/'));
+ $newdir = substr($params['newpath'], 0, strrpos($params['newpath'], '/'));
+ if ($olddir == '') $olddir = '/';
+ if ($newdir == '') $newdir = '/';
+ if (!self::isPhoto($params['newpath'])) return;
+ OC_Log::write(self::$APP_TAG, 'Moving photo from '.$params['oldpath'].' to '.$params['newpath'], OC_Log::DEBUG);
+ $album;
+ $newAlbumId;
+ $oldAlbumId;
+ if ($olddir == $newdir) {
+ // album changing is not needed
+ $album = OC_Gallery_Album::find(OC_User::getUser(), null, $olddir);
+ if ($album->numRows() == 0) {
+ $album = self::createAlbum($newdir);
+ }
+ $album = $album->fetchRow();
+ $newAlbumId = $oldAlbumId = $album['album_id'];
+ } else {
+ $newalbum = OC_Gallery_Album::find(OC_User::getUser(), null, $newdir);
+ $oldalbum = OC_Gallery_Album::find(OC_User::getUser(), null, $olddir);
+
+ if ($newalbum->numRows() == 0) {
+ $newalbum = self::createAlbum($newdir);
+ }
+ $newalbum = $newalbum->fetchRow();
+ if ($oldalbum->numRows() == 0) {
+ OC_Gallery_Photo::create($newalbum['album_id'], $params['newpath']);
+ return;
+ }
+ $oldalbum = $oldalbum->fetchRow();
+ $newAlbumId = $newalbum['album_id'];
+ $oldAlbumId = $oldalbum['album_id'];
+
+ }
+ OC_Gallery_Photo::changePath($oldAlbumId, $newAlbumId, $params['oldpath'], $params['newpath']);
+ }
+}
+
+?>
diff --git a/apps/gallery/lib/images_utils.php b/apps/gallery/lib/images_utils.php
index cb46bf3f160..0cfa52eb564 100644
--- a/apps/gallery/lib/images_utils.php
+++ b/apps/gallery/lib/images_utils.php
@@ -1,4 +1,26 @@
<?php
+
+/**
+* ownCloud - gallery application
+*
+* @author Bartek Przybylski
+* @copyright 2012 Bartek Przybylski bart.p.pl@gmail.com
+*
+* This library is free software; you can redistribute it and/or
+* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
+* License as published by the Free Software Foundation; either
+* version 3 of the License, or any later version.
+*
+* This library is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this library. If not, see <http://www.gnu.org/licenses/>.
+*
+*/
+
require_once('../../../lib/base.php');
OC_JSON::checkLoggedIn();
OC_JSON::checkAppEnabled('gallery');
diff --git a/apps/gallery/lib/photo.php b/apps/gallery/lib/photo.php
index 97d159935f5..23887098e0f 100644
--- a/apps/gallery/lib/photo.php
+++ b/apps/gallery/lib/photo.php
@@ -1,5 +1,26 @@
<?php
+/**
+* ownCloud - gallery application
+*
+* @author Bartek Przybylski
+* @copyright 2012 Bartek Przybylski bart.p.pl@gmail.com
+*
+* This library is free software; you can redistribute it and/or
+* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
+* License as published by the Free Software Foundation; either
+* version 3 of the License, or any later version.
+*
+* This library is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this library. If not, see <http://www.gnu.org/licenses/>.
+*
+*/
+
class OC_Gallery_Photo{
public static function create($albumId, $img){
$stmt = OC_DB::prepare('INSERT INTO *PREFIX*gallery_photos (album_id, file_path) VALUES (?, ?)');
@@ -8,7 +29,6 @@ class OC_Gallery_Photo{
public static function find($albumId, $img=null){
$sql = 'SELECT * FROM *PREFIX*gallery_photos WHERE album_id = ?';
$args = array($albumId);
- $args = array($albumId);
if (!is_null($img)){
$sql .= ' AND file_path = ?';
$args[] = $img;
@@ -25,4 +45,20 @@ class OC_Gallery_Photo{
.' AND photos.album_id = albums.album_id');
return $stmt->execute(array($owner, $album_name));
}
+
+ public static function removeByPath($path) {
+ $stmt = OC_DB::prepare('DELETE FROM *PREFIX*gallery_photos WHERE file_path = ?');
+ $stmt->execute(array($path));
+ }
+
+ public static function removeById($id) {
+ $stmt = OC_DB::prepare('DELETE FROM *PREFIX*gallery_photos WHERE photo_id = ?');
+ $stmt->execute(array($id));
+ }
+
+ public static function changePath($oldAlbumId, $newAlbumId, $oldpath, $newpath) {
+ $stmt = OC_DB::prepare("UPDATE *PREFIX*gallery_photos SET file_path = ?, album_id = ? WHERE album_id = ? and file_path = ?");
+ $stmt->execute(array($newpath, $newAlbumId, $oldAlbumId, $oldpath));
+ }
}
+
diff --git a/apps/gallery/lib/scanner.php b/apps/gallery/lib/scanner.php
index 59c34b8e69a..3eba9260ac7 100644
--- a/apps/gallery/lib/scanner.php
+++ b/apps/gallery/lib/scanner.php
@@ -1,5 +1,26 @@
<?php
+/**
+* ownCloud - gallery application
+*
+* @author Bartek Przybylski
+* @copyright 2012 Bartek Przybylski bart.p.pl@gmail.com
+*
+* This library is free software; you can redistribute it and/or
+* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
+* License as published by the Free Software Foundation; either
+* version 3 of the License, or any later version.
+*
+* This library is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this library. If not, see <http://www.gnu.org/licenses/>.
+*
+*/
+
require_once('base.php'); // base lib
require_once('images_utils.php');
@@ -21,13 +42,13 @@ class OC_Gallery_Scanner {
public static function scanDir($path, &$albums) {
$current_album = array('name'=> $path, 'imagesCount' => 0, 'images' => array());
$current_album['name'] = str_replace('/', '.', str_replace(OC::$CONFIG_DATADIRECTORY, '', $current_album['name']));
- $current_album['name'] = ($current_album['name']==='') ?
+ $current_album['name'] = ($current_album['name']==='.') ?
'main' :
trim($current_album['name'],'.');
if ($dh = OC_Filesystem::opendir($path)) {
while (($filename = readdir($dh)) !== false) {
- $filepath = $path.'/'.$filename;
+ $filepath = ($path[strlen($path)-1]=='/'?$path:$path.'/').$filename;
if (substr($filename, 0, 1) == '.') continue;
if (OC_Filesystem::is_dir($filepath)) {
self::scanDir($filepath, $albums);
@@ -41,7 +62,7 @@ class OC_Gallery_Scanner {
$result = OC_Gallery_Album::find(OC_User::getUser(), $current_album['name']);
if ($result->numRows() == 0 && count($current_album['images'])) {
- OC_Gallery_Album::create(OC_User::getUser(), $current_album['name']);
+ OC_Gallery_Album::create(OC_User::getUser(), $current_album['name'], $path);
$result = OC_Gallery_Album::find(OC_User::getUser(), $current_album['name']);
}
$albumId = $result->fetchRow();
diff --git a/apps/gallery/templates/index.php b/apps/gallery/templates/index.php
index 0e89e448768..7c6e91a468e 100644
--- a/apps/gallery/templates/index.php
+++ b/apps/gallery/templates/index.php
@@ -4,9 +4,10 @@ OC_Util::addScript('gallery', 'albums');
OC_Util::addScript('gallery', 'album_cover');
?>
+<div id="notification"><div id="gallery_notification_text">Creating thumbnails</div></div>
<div id="controls">
- <!-- <input type="button" value="New album" onclick="javascript:createNewAlbum();" />-->
- <input type="button" value="Rescan" onclick="javascript:scanForAlbums();" /><br/>
+ <input type="button" value="Rescan" onclick="javascript:scanForAlbums();" />
+ <br/>
</div>
<div id="gallery_list">
</div>
diff --git a/apps/media/css/music.css b/apps/media/css/music.css
index a6738058be3..41ade44a66f 100644
--- a/apps/media/css/music.css
+++ b/apps/media/css/music.css
@@ -22,11 +22,11 @@ div.jp-volume-bar-value { background:#ccc; width:0; height:0.4em; }
#collection li.album,#collection li.song { margin-left:3em; }
#leftcontent img.remove { display:none; float:right; cursor:pointer; }
#leftcontent li:hover img.remove { display:inline; }
-#leftcontent li {white-space: normal; }
+#leftcontent li div.label { float: left; width: 200px; overflow: hidden; text-overflow: ellipsis; }
#collection li button { float:right; }
#collection li,#playlist li { list-style-type:none; }
.template { display:none; }
-.collection_playing { background:#eee; }
+.collection_playing { background:#eee; font-weight: bold; }
#collection li { padding-right:10px; }
#searchresults input.play, #searchresults input.add { float:left; height:1em; width:1em; }
diff --git a/apps/media/js/jQuery.jPlayer.2.1.0.source/Jplayer.as b/apps/media/js/jQuery.jPlayer.2.1.0.source/Jplayer.as
new file mode 100644
index 00000000000..1178dacc345
--- /dev/null
+++ b/apps/media/js/jQuery.jPlayer.2.1.0.source/Jplayer.as
@@ -0,0 +1,415 @@
+/*
+ * jPlayer Plugin for jQuery JavaScript Library
+ * http://www.happyworm.com/jquery/jplayer
+ *
+ * Copyright (c) 2009 - 2011 Happyworm Ltd
+ * Dual licensed under the MIT and GPL licenses.
+ * - http://www.opensource.org/licenses/mit-license.php
+ * - http://www.gnu.org/copyleft/gpl.html
+ *
+ * Author: Mark J Panaghiston
+ * Version: 2.1.0
+ * Date: 1st September 2011
+ *
+ * FlashVars expected: (AS3 property of: loaderInfo.parameters)
+ * id: (URL Encoded: String) Id of jPlayer instance
+ * vol: (Number) Sets the initial volume
+ * muted: (Boolean in a String) Sets the initial muted state
+ * jQuery: (URL Encoded: String) Sets the jQuery var name. Used with: someVar = jQuery.noConflict(true);
+ *
+ * Compiled using: Adobe Flex Compiler (mxmlc) Version 4.5.1 build 21328
+ */
+
+package {
+ import flash.system.Security;
+ import flash.external.ExternalInterface;
+
+ import flash.utils.Timer;
+ import flash.events.TimerEvent;
+
+ import flash.text.TextField;
+ import flash.text.TextFormat;
+
+ import flash.events.KeyboardEvent;
+
+ import flash.display.Sprite;
+ import happyworm.jPlayer.*;
+
+ import flash.display.StageAlign;
+ import flash.display.StageScaleMode;
+ import flash.events.Event;
+ import flash.events.MouseEvent;
+
+ import flash.ui.ContextMenu;
+ import flash.ui.ContextMenuItem;
+ import flash.events.ContextMenuEvent;
+ import flash.net.URLRequest;
+ import flash.net.navigateToURL;
+
+ public class Jplayer extends Sprite {
+ private var jQuery:String;
+ private var sentNumberFractionDigits:uint = 2;
+
+ public var commonStatus:JplayerStatus = new JplayerStatus(); // Used for inital ready event so volume is correct.
+
+ private var myInitTimer:Timer = new Timer(100, 0);
+
+ private var myMp3Player:JplayerMp3;
+ private var myMp4Player:JplayerMp4;
+
+ private var isMp3:Boolean = false;
+ private var isVideo:Boolean = false;
+
+ private var txLog:TextField;
+ private var debug:Boolean = false; // Set debug to false for release compile!
+
+ public function Jplayer() {
+ flash.system.Security.allowDomain("*");
+
+ jQuery = loaderInfo.parameters.jQuery + "('#" + loaderInfo.parameters.id + "').jPlayer";
+ commonStatus.volume = Number(loaderInfo.parameters.vol);
+ commonStatus.muted = loaderInfo.parameters.muted == "true";
+
+ stage.scaleMode = StageScaleMode.NO_SCALE;
+ stage.align = StageAlign.TOP_LEFT;
+ stage.addEventListener(Event.RESIZE, resizeHandler);
+ stage.addEventListener(MouseEvent.CLICK, clickHandler);
+
+ var initialVolume:Number = commonStatus.volume;
+ if(commonStatus.muted) {
+ initialVolume = 0;
+ }
+ myMp3Player = new JplayerMp3(initialVolume);
+ addChild(myMp3Player);
+
+ myMp4Player = new JplayerMp4(initialVolume);
+ addChild(myMp4Player);
+
+ setupListeners(!isMp3, isMp3); // Set up the listeners to the default isMp3 state.
+
+ // The ContextMenu only partially works. The menu select events never occur.
+ // Investigated and it is something to do with the way jPlayer inserts the Flash on the page.
+ // A simple test inserting the Jplayer.swf on a page using: 1) SWFObject 2.2 works. 2) AC_FL_RunContent() works.
+ // jPlayer Flash insertion is based on SWFObject 2.2 and the resaon behind this failure is not clear. The Flash insertion HTML on the page looks similar.
+ var myContextMenu:ContextMenu = new ContextMenu();
+ myContextMenu.hideBuiltInItems();
+ var menuItem_jPlayer:ContextMenuItem = new ContextMenuItem("jPlayer " + JplayerStatus.VERSION);
+ var menuItem_happyworm:ContextMenuItem = new ContextMenuItem("© 2009-2011 Happyworm Ltd", true);
+ menuItem_jPlayer.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, menuSelectHandler_jPlayer);
+ menuItem_happyworm.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, menuSelectHandler_happyworm);
+ myContextMenu.customItems.push(menuItem_jPlayer, menuItem_happyworm);
+ contextMenu = myContextMenu;
+
+ // Log console for dev compile option: debug
+ if(debug) {
+ txLog = new TextField();
+ txLog.x = 5;
+ txLog.y = 5;
+ txLog.width = 540;
+ txLog.height = 390;
+ txLog.border = true;
+ txLog.background = true;
+ txLog.backgroundColor = 0xEEEEFF;
+ txLog.multiline = true;
+ txLog.text = "jPlayer " + JplayerStatus.VERSION;
+ txLog.visible = false;
+ this.addChild(txLog);
+ this.stage.addEventListener(KeyboardEvent.KEY_UP, keyboardHandler);
+
+ myMp3Player.addEventListener(JplayerEvent.DEBUG_MSG, debugMsgHandler);
+ myMp4Player.addEventListener(JplayerEvent.DEBUG_MSG, debugMsgHandler);
+ }
+
+ // Delay init() because Firefox 3.5.7+ developed a bug with local testing in Firebug.
+ myInitTimer.addEventListener(TimerEvent.TIMER, init);
+ myInitTimer.start();
+ }
+
+ private function init(e:TimerEvent):void {
+ myInitTimer.stop();
+ if(ExternalInterface.available) {
+ ExternalInterface.addCallback("fl_setAudio_mp3", fl_setAudio_mp3);
+ ExternalInterface.addCallback("fl_setAudio_m4a", fl_setAudio_m4a);
+ ExternalInterface.addCallback("fl_setVideo_m4v", fl_setVideo_m4v);
+ ExternalInterface.addCallback("fl_clearMedia", fl_clearMedia);
+ ExternalInterface.addCallback("fl_load", fl_load);
+ ExternalInterface.addCallback("fl_play", fl_play);
+ ExternalInterface.addCallback("fl_pause", fl_pause);
+ ExternalInterface.addCallback("fl_play_head", fl_play_head);
+ ExternalInterface.addCallback("fl_volume", fl_volume);
+ ExternalInterface.addCallback("fl_mute", fl_mute);
+
+ ExternalInterface.call(jQuery, "jPlayerFlashEvent", JplayerEvent.JPLAYER_READY, extractStatusData(commonStatus)); // See JplayerStatus() class for version number.
+ }
+ }
+ private function setupListeners(oldMP3:Boolean, newMP3:Boolean):void {
+ if(oldMP3 != newMP3) {
+ if(newMP3) {
+ listenToMp3(true);
+ listenToMp4(false);
+ } else {
+ listenToMp3(false);
+ listenToMp4(true);
+ }
+ }
+ }
+ private function listenToMp3(active:Boolean):void {
+ if(active) {
+ myMp3Player.addEventListener(JplayerEvent.JPLAYER_ERROR, jPlayerFlashEvent);
+ myMp3Player.addEventListener(JplayerEvent.JPLAYER_PROGRESS, jPlayerFlashEvent);
+ myMp3Player.addEventListener(JplayerEvent.JPLAYER_TIMEUPDATE, jPlayerFlashEvent);
+ myMp3Player.addEventListener(JplayerEvent.JPLAYER_ENDED, jPlayerFlashEvent);
+
+ myMp3Player.addEventListener(JplayerEvent.JPLAYER_PLAY, jPlayerFlashEvent);
+ myMp3Player.addEventListener(JplayerEvent.JPLAYER_PAUSE, jPlayerFlashEvent);
+ myMp3Player.addEventListener(JplayerEvent.JPLAYER_LOADSTART, jPlayerFlashEvent);
+
+ myMp3Player.addEventListener(JplayerEvent.JPLAYER_SEEKING, jPlayerFlashEvent);
+ myMp3Player.addEventListener(JplayerEvent.JPLAYER_SEEKED, jPlayerFlashEvent);
+ } else {
+ myMp3Player.removeEventListener(JplayerEvent.JPLAYER_ERROR, jPlayerFlashEvent);
+ myMp3Player.removeEventListener(JplayerEvent.JPLAYER_PROGRESS, jPlayerFlashEvent);
+ myMp3Player.removeEventListener(JplayerEvent.JPLAYER_TIMEUPDATE, jPlayerFlashEvent);
+ myMp3Player.removeEventListener(JplayerEvent.JPLAYER_ENDED, jPlayerFlashEvent);
+
+ myMp3Player.removeEventListener(JplayerEvent.JPLAYER_PLAY, jPlayerFlashEvent);
+ myMp3Player.removeEventListener(JplayerEvent.JPLAYER_PAUSE, jPlayerFlashEvent);
+ myMp3Player.removeEventListener(JplayerEvent.JPLAYER_LOADSTART, jPlayerFlashEvent);
+
+ myMp3Player.removeEventListener(JplayerEvent.JPLAYER_SEEKING, jPlayerFlashEvent);
+ myMp3Player.removeEventListener(JplayerEvent.JPLAYER_SEEKED, jPlayerFlashEvent);
+ }
+ }
+ private function listenToMp4(active:Boolean):void {
+ if(active) {
+ myMp4Player.addEventListener(JplayerEvent.JPLAYER_ERROR, jPlayerFlashEvent);
+ myMp4Player.addEventListener(JplayerEvent.JPLAYER_PROGRESS, jPlayerFlashEvent);
+ myMp4Player.addEventListener(JplayerEvent.JPLAYER_TIMEUPDATE, jPlayerFlashEvent);
+ myMp4Player.addEventListener(JplayerEvent.JPLAYER_ENDED, jPlayerFlashEvent);
+
+ myMp4Player.addEventListener(JplayerEvent.JPLAYER_PLAY, jPlayerFlashEvent);
+ myMp4Player.addEventListener(JplayerEvent.JPLAYER_PAUSE, jPlayerFlashEvent);
+ myMp4Player.addEventListener(JplayerEvent.JPLAYER_LOADSTART, jPlayerFlashEvent);
+
+ myMp4Player.addEventListener(JplayerEvent.JPLAYER_SEEKING, jPlayerFlashEvent);
+ myMp4Player.addEventListener(JplayerEvent.JPLAYER_SEEKED, jPlayerFlashEvent);
+
+ myMp4Player.addEventListener(JplayerEvent.JPLAYER_LOADEDMETADATA, jPlayerMetaDataHandler); // Note the unique handler
+ } else {
+ myMp4Player.removeEventListener(JplayerEvent.JPLAYER_ERROR, jPlayerFlashEvent);
+ myMp4Player.removeEventListener(JplayerEvent.JPLAYER_PROGRESS, jPlayerFlashEvent);
+ myMp4Player.removeEventListener(JplayerEvent.JPLAYER_TIMEUPDATE, jPlayerFlashEvent);
+ myMp4Player.removeEventListener(JplayerEvent.JPLAYER_ENDED, jPlayerFlashEvent);
+
+ myMp4Player.removeEventListener(JplayerEvent.JPLAYER_PLAY, jPlayerFlashEvent);
+ myMp4Player.removeEventListener(JplayerEvent.JPLAYER_PAUSE, jPlayerFlashEvent);
+ myMp4Player.removeEventListener(JplayerEvent.JPLAYER_LOADSTART, jPlayerFlashEvent);
+
+ myMp4Player.removeEventListener(JplayerEvent.JPLAYER_SEEKING, jPlayerFlashEvent);
+ myMp4Player.removeEventListener(JplayerEvent.JPLAYER_SEEKED, jPlayerFlashEvent);
+
+ myMp4Player.removeEventListener(JplayerEvent.JPLAYER_LOADEDMETADATA, jPlayerMetaDataHandler); // Note the unique handler
+ }
+ }
+ private function fl_setAudio_mp3(src:String):Boolean {
+ if (src != null) {
+ log("fl_setAudio_mp3: "+src);
+ setupListeners(isMp3, true);
+ isMp3 = true;
+ isVideo = false;
+ myMp4Player.clearFile();
+ myMp3Player.setFile(src);
+ return true;
+ } else {
+ log("fl_setAudio_mp3: null");
+ return false;
+ }
+ }
+ private function fl_setAudio_m4a(src:String):Boolean {
+ if (src != null) {
+ log("fl_setAudio_m4a: "+src);
+ setupListeners(isMp3, false);
+ isMp3 = false;
+ isVideo = false;
+ myMp3Player.clearFile();
+ myMp4Player.setFile(src);
+ return true;
+ } else {
+ log("fl_setAudio_m4a: null");
+ return false;
+ }
+ }
+ private function fl_setVideo_m4v(src:String):Boolean {
+ if (src != null) {
+ log("fl_setVideo_m4v: "+src);
+ setupListeners(isMp3, false);
+ isMp3 = false;
+ isVideo = true;
+ myMp3Player.clearFile();
+ myMp4Player.setFile(src);
+ return true;
+ } else {
+ log("fl_setVideo_m4v: null");
+ return false;
+ }
+ }
+ private function fl_clearMedia():void {
+ log("clearMedia.");
+ myMp3Player.clearFile();
+ myMp4Player.clearFile();
+ }
+ private function fl_load():Boolean {
+ log("load.");
+ if(isMp3) {
+ return myMp3Player.load();
+ } else {
+ return myMp4Player.load();
+ }
+ }
+ private function fl_play(time:Number = NaN):Boolean {
+ log("play: time = " + time);
+ if(isMp3) {
+ return myMp3Player.play(time * 1000); // Flash uses milliseconds
+ } else {
+ return myMp4Player.play(time * 1000); // Flash uses milliseconds
+ }
+ }
+ private function fl_pause(time:Number = NaN):Boolean {
+ log("pause: time = " + time);
+ if(isMp3) {
+ return myMp3Player.pause(time * 1000); // Flash uses milliseconds
+ } else {
+ return myMp4Player.pause(time * 1000); // Flash uses milliseconds
+ }
+ }
+ private function fl_play_head(percent:Number):Boolean {
+ log("play_head: "+percent+"%");
+ if(isMp3) {
+ return myMp3Player.playHead(percent);
+ } else {
+ return myMp4Player.playHead(percent);
+ }
+ }
+ private function fl_volume(v:Number):void {
+ log("volume: "+v);
+ commonStatus.volume = v;
+ if(!commonStatus.muted) {
+ myMp3Player.setVolume(v);
+ myMp4Player.setVolume(v);
+ }
+ }
+ private function fl_mute(mute:Boolean):void {
+ log("mute: "+mute);
+ commonStatus.muted = mute;
+ if(mute) {
+ myMp3Player.setVolume(0);
+ myMp4Player.setVolume(0);
+ } else {
+ myMp3Player.setVolume(commonStatus.volume);
+ myMp4Player.setVolume(commonStatus.volume);
+ }
+ }
+ private function jPlayerFlashEvent(e:JplayerEvent):void {
+ log("jPlayer Flash Event: " + e.type + ": " + e.target);
+ if(ExternalInterface.available) {
+ ExternalInterface.call(jQuery, "jPlayerFlashEvent", e.type, extractStatusData(e.data));
+ }
+ }
+ private function extractStatusData(data:JplayerStatus):Object {
+ var myStatus:Object = {
+ version: JplayerStatus.VERSION,
+ src: data.src,
+ paused: !data.isPlaying, // Changing this name requires inverting all assignments and conditional statements.
+ srcSet: data.srcSet,
+ seekPercent: data.seekPercent,
+ currentPercentRelative: data.currentPercentRelative,
+ currentPercentAbsolute: data.currentPercentAbsolute,
+ currentTime: data.currentTime / 1000, // JavaScript uses seconds
+ duration: data.duration / 1000, // JavaScript uses seconds
+ volume: commonStatus.volume,
+ muted: commonStatus.muted
+ };
+ log("extractStatusData: sp="+myStatus.seekPercent+" cpr="+myStatus.currentPercentRelative+" cpa="+myStatus.currentPercentAbsolute+" ct="+myStatus.currentTime+" d="+myStatus.duration);
+ return myStatus;
+ }
+ private function jPlayerMetaDataHandler(e:JplayerEvent):void {
+ log("jPlayerMetaDataHandler:" + e.target);
+ if(ExternalInterface.available) {
+ resizeHandler(new Event(Event.RESIZE));
+ ExternalInterface.call(jQuery, "jPlayerFlashEvent", e.type, extractStatusData(e.data));
+ }
+ }
+ private function resizeHandler(e:Event):void {
+ log("resizeHandler: stageWidth = " + stage.stageWidth + " | stageHeight = " + stage.stageHeight);
+
+ var mediaX:Number = 0;
+ var mediaY:Number = 0;
+ var mediaWidth:Number = 0;
+ var mediaHeight:Number = 0;
+
+ if(stage.stageWidth > 0 && stage.stageHeight > 0 && myMp4Player.myVideo.width > 0 && myMp4Player.myVideo.height > 0) {
+ var aspectRatioStage:Number = stage.stageWidth / stage.stageHeight;
+ var aspectRatioVideo:Number = myMp4Player.myVideo.width / myMp4Player.myVideo.height;
+ if(aspectRatioStage < aspectRatioVideo) {
+ mediaWidth = stage.stageWidth;
+ mediaHeight = stage.stageWidth / aspectRatioVideo;
+ mediaX = 0;
+ mediaY = (stage.stageHeight - mediaHeight) / 2;
+ } else {
+ mediaWidth = stage.stageHeight * aspectRatioVideo;
+ mediaHeight = stage.stageHeight;
+ mediaX = (stage.stageWidth - mediaWidth) / 2;
+ mediaY = 0;
+ }
+ resizeEntity(myMp4Player, mediaX, mediaY, mediaWidth, mediaHeight);
+ }
+ if(debug && stage.stageWidth > 20 && stage.stageHeight > 20) {
+ txLog.width = stage.stageWidth - 10;
+ txLog.height = stage.stageHeight - 10;
+ }
+ }
+ private function resizeEntity(entity:Sprite, mediaX:Number, mediaY:Number, mediaWidth:Number, mediaHeight:Number):void {
+ entity.x = mediaX;
+ entity.y = mediaY;
+ entity.width = mediaWidth;
+ entity.height = mediaHeight;
+ }
+ private function clickHandler(e:MouseEvent):void {
+ if(isMp3) {
+ jPlayerFlashEvent(new JplayerEvent(JplayerEvent.JPLAYER_CLICK, myMp3Player.myStatus, "click"))
+ } else {
+ jPlayerFlashEvent(new JplayerEvent(JplayerEvent.JPLAYER_CLICK, myMp4Player.myStatus, "click"))
+ }
+ }
+ // This event is never called. See comments in class constructor.
+ private function menuSelectHandler_jPlayer(e:ContextMenuEvent):void {
+ navigateToURL(new URLRequest("http://jplayer.org/"), "_blank");
+ }
+ // This event is never called. See comments in class constructor.
+ private function menuSelectHandler_happyworm(e:ContextMenuEvent):void {
+ navigateToURL(new URLRequest("http://happyworm.com/"), "_blank");
+ }
+ private function log(t:String):void {
+ if(debug) {
+ txLog.text = t + "\n" + txLog.text;
+ }
+ }
+ private function debugMsgHandler(e:JplayerEvent):void {
+ log(e.msg);
+ }
+ private function keyboardHandler(e:KeyboardEvent):void {
+ log("keyboardHandler: e.keyCode = " + e.keyCode);
+ switch(e.keyCode) {
+ case 68 : // d
+ txLog.visible = !txLog.visible;
+ log("Toggled log display: " + txLog.visible);
+ break;
+ case 76 : // l
+ if(e.ctrlKey && e.shiftKey) {
+ txLog.text = "Cleared log.";
+ }
+ break;
+ }
+ }
+ }
+}
diff --git a/apps/media/js/jQuery.jPlayer.2.1.0.source/Jplayer.fla b/apps/media/js/jQuery.jPlayer.2.1.0.source/Jplayer.fla
new file mode 100644
index 00000000000..61ae40d3ac2
--- /dev/null
+++ b/apps/media/js/jQuery.jPlayer.2.1.0.source/Jplayer.fla
Binary files differ
diff --git a/apps/media/js/jQuery.jPlayer.2.1.0.source/add-on/jplayer.playlist.js b/apps/media/js/jQuery.jPlayer.2.1.0.source/add-on/jplayer.playlist.js
new file mode 100644
index 00000000000..0eaa0ddf3d7
--- /dev/null
+++ b/apps/media/js/jQuery.jPlayer.2.1.0.source/add-on/jplayer.playlist.js
@@ -0,0 +1,452 @@
+/*
+ * Playlist Object for the jPlayer Plugin
+ * http://www.jplayer.org
+ *
+ * Copyright (c) 2009 - 2011 Happyworm Ltd
+ * Dual licensed under the MIT and GPL licenses.
+ * - http://www.opensource.org/licenses/mit-license.php
+ * - http://www.gnu.org/copyleft/gpl.html
+ *
+ * Author: Mark J Panaghiston
+ * Version: 2.1.0 (jPlayer 2.1.0)
+ * Date: 1st September 2011
+ */
+
+/* Code verified using http://www.jshint.com/ */
+/*jshint asi:false, bitwise:false, boss:false, browser:true, curly:true, debug:false, eqeqeq:true, eqnull:false, evil:false, forin:false, immed:false, jquery:true, laxbreak:false, newcap:true, noarg:true, noempty:true, nonew:true, nomem:false, onevar:false, passfail:false, plusplus:false, regexp:false, undef:true, sub:false, strict:false, white:false */
+/*global jPlayerPlaylist: true, jQuery:false, alert:false */
+
+(function($, undefined) {
+
+ jPlayerPlaylist = function(cssSelector, playlist, options) {
+ var self = this;
+
+ this.current = 0;
+ this.loop = false; // Flag used with the jPlayer repeat event
+ this.shuffled = false;
+ this.removing = false; // Flag is true during remove animation, disabling the remove() method until complete.
+
+ this.cssSelector = $.extend({}, this._cssSelector, cssSelector); // Object: Containing the css selectors for jPlayer and its cssSelectorAncestor
+ this.options = $.extend(true, {}, this._options, options); // Object: The jPlayer constructor options for this playlist and the playlist options
+
+ this.playlist = []; // Array of Objects: The current playlist displayed (Un-shuffled or Shuffled)
+ this.original = []; // Array of Objects: The original playlist
+
+ this._initPlaylist(playlist); // Copies playlist to this.original. Then mirrors this.original to this.playlist. Creating two arrays, where the element pointers match. (Enables pointer comparison.)
+
+ // Setup the css selectors for the extra interface items used by the playlist.
+ this.cssSelector.title = this.cssSelector.cssSelectorAncestor + " .jp-title"; // Note that the text is written to the decendant li node.
+ this.cssSelector.playlist = this.cssSelector.cssSelectorAncestor + " .jp-playlist";
+ this.cssSelector.next = this.cssSelector.cssSelectorAncestor + " .jp-next";
+ this.cssSelector.previous = this.cssSelector.cssSelectorAncestor + " .jp-previous";
+ this.cssSelector.shuffle = this.cssSelector.cssSelectorAncestor + " .jp-shuffle";
+ this.cssSelector.shuffleOff = this.cssSelector.cssSelectorAncestor + " .jp-shuffle-off";
+
+ // Override the cssSelectorAncestor given in options
+ this.options.cssSelectorAncestor = this.cssSelector.cssSelectorAncestor;
+
+ // Override the default repeat event handler
+ this.options.repeat = function(event) {
+ self.loop = event.jPlayer.options.loop;
+ };
+
+ // Create a ready event handler to initialize the playlist
+ $(this.cssSelector.jPlayer).bind($.jPlayer.event.ready, function(event) {
+ self._init();
+ });
+
+ // Create an ended event handler to move to the next item
+ $(this.cssSelector.jPlayer).bind($.jPlayer.event.ended, function(event) {
+ self.next();
+ });
+
+ // Create a play event handler to pause other instances
+ $(this.cssSelector.jPlayer).bind($.jPlayer.event.play, function(event) {
+ $(this).jPlayer("pauseOthers");
+ });
+
+ // Create a resize event handler to show the title in full screen mode.
+ $(this.cssSelector.jPlayer).bind($.jPlayer.event.resize, function(event) {
+ if(event.jPlayer.options.fullScreen) {
+ $(self.cssSelector.title).show();
+ } else {
+ $(self.cssSelector.title).hide();
+ }
+ });
+
+ // Create click handlers for the extra buttons that do playlist functions.
+ $(this.cssSelector.previous).click(function() {
+ self.previous();
+ $(this).blur();
+ return false;
+ });
+
+ $(this.cssSelector.next).click(function() {
+ self.next();
+ $(this).blur();
+ return false;
+ });
+
+ $(this.cssSelector.shuffle).click(function() {
+ self.shuffle(true);
+ return false;
+ });
+ $(this.cssSelector.shuffleOff).click(function() {
+ self.shuffle(false);
+ return false;
+ }).hide();
+
+ // Put the title in its initial display state
+ if(!this.options.fullScreen) {
+ $(this.cssSelector.title).hide();
+ }
+
+ // Remove the empty <li> from the page HTML. Allows page to be valid HTML, while not interfereing with display animations
+ $(this.cssSelector.playlist + " ul").empty();
+
+ // Create .live() handlers for the playlist items along with the free media and remove controls.
+ this._createItemHandlers();
+
+ // Instance jPlayer
+ $(this.cssSelector.jPlayer).jPlayer(this.options);
+ };
+
+ jPlayerPlaylist.prototype = {
+ _cssSelector: { // static object, instanced in constructor
+ jPlayer: "#jquery_jplayer_1",
+ cssSelectorAncestor: "#jp_container_1"
+ },
+ _options: { // static object, instanced in constructor
+ playlistOptions: {
+ autoPlay: false,
+ loopOnPrevious: false,
+ shuffleOnLoop: true,
+ enableRemoveControls: false,
+ displayTime: 'slow',
+ addTime: 'fast',
+ removeTime: 'fast',
+ shuffleTime: 'slow',
+ itemClass: "jp-playlist-item",
+ freeGroupClass: "jp-free-media",
+ freeItemClass: "jp-playlist-item-free",
+ removeItemClass: "jp-playlist-item-remove"
+ }
+ },
+ option: function(option, value) { // For changing playlist options only
+ if(value === undefined) {
+ return this.options.playlistOptions[option];
+ }
+
+ this.options.playlistOptions[option] = value;
+
+ switch(option) {
+ case "enableRemoveControls":
+ this._updateControls();
+ break;
+ case "itemClass":
+ case "freeGroupClass":
+ case "freeItemClass":
+ case "removeItemClass":
+ this._refresh(true); // Instant
+ this._createItemHandlers();
+ break;
+ }
+ return this;
+ },
+ _init: function() {
+ var self = this;
+ this._refresh(function() {
+ if(self.options.playlistOptions.autoPlay) {
+ self.play(self.current);
+ } else {
+ self.select(self.current);
+ }
+ });
+ },
+ _initPlaylist: function(playlist) {
+ this.current = 0;
+ this.shuffled = false;
+ this.removing = false;
+ this.original = $.extend(true, [], playlist); // Copy the Array of Objects
+ this._originalPlaylist();
+ },
+ _originalPlaylist: function() {
+ var self = this;
+ this.playlist = [];
+ // Make both arrays point to the same object elements. Gives us 2 different arrays, each pointing to the same actual object. ie., Not copies of the object.
+ $.each(this.original, function(i,v) {
+ self.playlist[i] = self.original[i];
+ });
+ },
+ _refresh: function(instant) {
+ /* instant: Can be undefined, true or a function.
+ * undefined -> use animation timings
+ * true -> no animation
+ * function -> use animation timings and excute function at half way point.
+ */
+ var self = this;
+
+ if(instant && !$.isFunction(instant)) {
+ $(this.cssSelector.playlist + " ul").empty();
+ $.each(this.playlist, function(i,v) {
+ $(self.cssSelector.playlist + " ul").append(self._createListItem(self.playlist[i]));
+ });
+ this._updateControls();
+ } else {
+ var displayTime = $(this.cssSelector.playlist + " ul").children().length ? this.options.playlistOptions.displayTime : 0;
+
+ $(this.cssSelector.playlist + " ul").slideUp(displayTime, function() {
+ var $this = $(this);
+ $(this).empty();
+
+ $.each(self.playlist, function(i,v) {
+ $this.append(self._createListItem(self.playlist[i]));
+ });
+ self._updateControls();
+ if($.isFunction(instant)) {
+ instant();
+ }
+ if(self.playlist.length) {
+ $(this).slideDown(self.options.playlistOptions.displayTime);
+ } else {
+ $(this).show();
+ }
+ });
+ }
+ },
+ _createListItem: function(media) {
+ var self = this;
+
+ // Wrap the <li> contents in a <div>
+ var listItem = "<li><div>";
+
+ // Create remove control
+ listItem += "<a href='javascript:;' class='" + this.options.playlistOptions.removeItemClass + "'>&times;</a>";
+
+ // Create links to free media
+ if(media.free) {
+ var first = true;
+ listItem += "<span class='" + this.options.playlistOptions.freeGroupClass + "'>(";
+ $.each(media, function(property,value) {
+ if($.jPlayer.prototype.format[property]) { // Check property is a media format.
+ if(first) {
+ first = false;
+ } else {
+ listItem += " | ";
+ }
+ listItem += "<a class='" + self.options.playlistOptions.freeItemClass + "' href='" + value + "' tabindex='1'>" + property + "</a>";
+ }
+ });
+ listItem += ")</span>";
+ }
+
+ // The title is given next in the HTML otherwise the float:right on the free media corrupts in IE6/7
+ listItem += "<a href='javascript:;' class='" + this.options.playlistOptions.itemClass + "' tabindex='1'>" + media.title + (media.artist ? " <span class='jp-artist'>by " + media.artist + "</span>" : "") + "</a>";
+ listItem += "</div></li>";
+
+ return listItem;
+ },
+ _createItemHandlers: function() {
+ var self = this;
+ // Create .live() handlers for the playlist items
+ $(this.cssSelector.playlist + " a." + this.options.playlistOptions.itemClass).die("click").live("click", function() {
+ var index = $(this).parent().parent().index();
+ if(self.current !== index) {
+ self.play(index);
+ } else {
+ $(self.cssSelector.jPlayer).jPlayer("play");
+ }
+ $(this).blur();
+ return false;
+ });
+
+ // Create .live() handlers that disable free media links to force access via right click
+ $(self.cssSelector.playlist + " a." + this.options.playlistOptions.freeItemClass).die("click").live("click", function() {
+ $(this).parent().parent().find("." + self.options.playlistOptions.itemClass).click();
+ $(this).blur();
+ return false;
+ });
+
+ // Create .live() handlers for the remove controls
+ $(self.cssSelector.playlist + " a." + this.options.playlistOptions.removeItemClass).die("click").live("click", function() {
+ var index = $(this).parent().parent().index();
+ self.remove(index);
+ $(this).blur();
+ return false;
+ });
+ },
+ _updateControls: function() {
+ if(this.options.playlistOptions.enableRemoveControls) {
+ $(this.cssSelector.playlist + " ." + this.options.playlistOptions.removeItemClass).show();
+ } else {
+ $(this.cssSelector.playlist + " ." + this.options.playlistOptions.removeItemClass).hide();
+ }
+ if(this.shuffled) {
+ $(this.cssSelector.shuffleOff).show();
+ $(this.cssSelector.shuffle).hide();
+ } else {
+ $(this.cssSelector.shuffleOff).hide();
+ $(this.cssSelector.shuffle).show();
+ }
+ },
+ _highlight: function(index) {
+ if(this.playlist.length && index !== undefined) {
+ $(this.cssSelector.playlist + " .jp-playlist-current").removeClass("jp-playlist-current");
+ $(this.cssSelector.playlist + " li:nth-child(" + (index + 1) + ")").addClass("jp-playlist-current").find(".jp-playlist-item").addClass("jp-playlist-current");
+ $(this.cssSelector.title + " li").html(this.playlist[index].title + (this.playlist[index].artist ? " <span class='jp-artist'>by " + this.playlist[index].artist + "</span>" : ""));
+ }
+ },
+ setPlaylist: function(playlist) {
+ this._initPlaylist(playlist);
+ this._init();
+ },
+ add: function(media, playNow) {
+ $(this.cssSelector.playlist + " ul").append(this._createListItem(media)).find("li:last-child").hide().slideDown(this.options.playlistOptions.addTime);
+ this._updateControls();
+ this.original.push(media);
+ this.playlist.push(media); // Both array elements share the same object pointer. Comforms with _initPlaylist(p) system.
+
+ if(playNow) {
+ this.play(this.playlist.length - 1);
+ } else {
+ if(this.original.length === 1) {
+ this.select(0);
+ }
+ }
+ },
+ remove: function(index) {
+ var self = this;
+
+ if(index === undefined) {
+ this._initPlaylist([]);
+ this._refresh(function() {
+ $(self.cssSelector.jPlayer).jPlayer("clearMedia");
+ });
+ return true;
+ } else {
+
+ if(this.removing) {
+ return false;
+ } else {
+ index = (index < 0) ? self.original.length + index : index; // Negative index relates to end of array.
+ if(0 <= index && index < this.playlist.length) {
+ this.removing = true;
+
+ $(this.cssSelector.playlist + " li:nth-child(" + (index + 1) + ")").slideUp(this.options.playlistOptions.removeTime, function() {
+ $(this).remove();
+
+ if(self.shuffled) {
+ var item = self.playlist[index];
+ $.each(self.original, function(i,v) {
+ if(self.original[i] === item) {
+ self.original.splice(i, 1);
+ return false; // Exit $.each
+ }
+ });
+ self.playlist.splice(index, 1);
+ } else {
+ self.original.splice(index, 1);
+ self.playlist.splice(index, 1);
+ }
+
+ if(self.original.length) {
+ if(index === self.current) {
+ self.current = (index < self.original.length) ? self.current : self.original.length - 1; // To cope when last element being selected when it was removed
+ self.select(self.current);
+ } else if(index < self.current) {
+ self.current--;
+ }
+ } else {
+ $(self.cssSelector.jPlayer).jPlayer("clearMedia");
+ self.current = 0;
+ self.shuffled = false;
+ self._updateControls();
+ }
+
+ self.removing = false;
+ });
+ }
+ return true;
+ }
+ }
+ },
+ select: function(index) {
+ index = (index < 0) ? this.original.length + index : index; // Negative index relates to end of array.
+ if(0 <= index && index < this.playlist.length) {
+ this.current = index;
+ this._highlight(index);
+ $(this.cssSelector.jPlayer).jPlayer("setMedia", this.playlist[this.current]);
+ } else {
+ this.current = 0;
+ }
+ },
+ play: function(index) {
+ index = (index < 0) ? this.original.length + index : index; // Negative index relates to end of array.
+ if(0 <= index && index < this.playlist.length) {
+ if(this.playlist.length) {
+ this.select(index);
+ $(this.cssSelector.jPlayer).jPlayer("play");
+ }
+ } else if(index === undefined) {
+ $(this.cssSelector.jPlayer).jPlayer("play");
+ }
+ },
+ pause: function() {
+ $(this.cssSelector.jPlayer).jPlayer("pause");
+ },
+ next: function() {
+ var index = (this.current + 1 < this.playlist.length) ? this.current + 1 : 0;
+
+ if(this.loop) {
+ // See if we need to shuffle before looping to start, and only shuffle if more than 1 item.
+ if(index === 0 && this.shuffled && this.options.playlistOptions.shuffleOnLoop && this.playlist.length > 1) {
+ this.shuffle(true, true); // playNow
+ } else {
+ this.play(index);
+ }
+ } else {
+ // The index will be zero if it just looped round
+ if(index > 0) {
+ this.play(index);
+ }
+ }
+ },
+ previous: function() {
+ var index = (this.current - 1 >= 0) ? this.current - 1 : this.playlist.length - 1;
+
+ if(this.loop && this.options.playlistOptions.loopOnPrevious || index < this.playlist.length - 1) {
+ this.play(index);
+ }
+ },
+ shuffle: function(shuffled, playNow) {
+ var self = this;
+
+ if(shuffled === undefined) {
+ shuffled = !this.shuffled;
+ }
+
+ if(shuffled || shuffled !== this.shuffled) {
+
+ $(this.cssSelector.playlist + " ul").slideUp(this.options.playlistOptions.shuffleTime, function() {
+ self.shuffled = shuffled;
+ if(shuffled) {
+ self.playlist.sort(function() {
+ return 0.5 - Math.random();
+ });
+ } else {
+ self._originalPlaylist();
+ }
+ self._refresh(true); // Instant
+
+ if(playNow || !$(self.cssSelector.jPlayer).data("jPlayer").status.paused) {
+ self.play(0);
+ } else {
+ self.select(0);
+ }
+
+ $(this).slideDown(self.options.playlistOptions.shuffleTime);
+ });
+ }
+ }
+ };
+})(jQuery);
diff --git a/apps/media/js/jQuery.jPlayer.2.1.0.source/add-on/jquery.jplayer.inspector.js b/apps/media/js/jQuery.jPlayer.2.1.0.source/add-on/jquery.jplayer.inspector.js
new file mode 100644
index 00000000000..46c090a1b01
--- /dev/null
+++ b/apps/media/js/jQuery.jPlayer.2.1.0.source/add-on/jquery.jplayer.inspector.js
@@ -0,0 +1,331 @@
+/*
+ * jPlayerInspector Plugin for jPlayer (2.0.0+) Plugin for jQuery JavaScript Library
+ * http://www.happyworm.com/jquery/jplayer
+ *
+ * Copyright (c) 2009 - 2011 Happyworm Ltd
+ * Dual licensed under the MIT and GPL licenses.
+ * - http://www.opensource.org/licenses/mit-license.php
+ * - http://www.gnu.org/copyleft/gpl.html
+ *
+ * Author: Mark J Panaghiston
+ * Version: 1.0.3
+ * Date: 7th August 2011
+ *
+ * For use with jPlayer Version: 2.0.29
+ *
+ * Note: Declare inspector instances after jPlayer instances. ie., Otherwise the jPlayer instance is nonsense.
+ */
+
+(function($, undefined) {
+ $.jPlayerInspector = {};
+ $.jPlayerInspector.i = 0;
+ $.jPlayerInspector.defaults = {
+ jPlayer: undefined, // The jQuery selector of the jPlayer instance to inspect.
+ idPrefix: "jplayer_inspector_",
+ visible: false
+ };
+
+ var methods = {
+ init: function(options) {
+ var self = this;
+ var $this = $(this);
+
+ var config = $.extend({}, $.jPlayerInspector.defaults, options);
+ $(this).data("jPlayerInspector", config);
+
+ config.id = $(this).attr("id");
+ config.jPlayerId = config.jPlayer.attr("id");
+
+ config.windowId = config.idPrefix + "window_" + $.jPlayerInspector.i;
+ config.statusId = config.idPrefix + "status_" + $.jPlayerInspector.i;
+ config.configId = config.idPrefix + "config_" + $.jPlayerInspector.i;
+ config.toggleId = config.idPrefix + "toggle_" + $.jPlayerInspector.i;
+ config.eventResetId = config.idPrefix + "event_reset_" + $.jPlayerInspector.i;
+ config.updateId = config.idPrefix + "update_" + $.jPlayerInspector.i;
+ config.eventWindowId = config.idPrefix + "event_window_" + $.jPlayerInspector.i;
+
+ config.eventId = {};
+ config.eventJq = {};
+ config.eventTimeout = {};
+ config.eventOccurrence = {};
+
+ $.each($.jPlayer.event, function(eventName,eventType) {
+ config.eventId[eventType] = config.idPrefix + "event_" + eventName + "_" + $.jPlayerInspector.i;
+ config.eventOccurrence[eventType] = 0;
+ });
+
+ var structure =
+ '<p><a href="#" id="' + config.toggleId + '">' + (config.visible ? "Hide" : "Show") + '</a> jPlayer Inspector</p>'
+ + '<div id="' + config.windowId + '">'
+ + '<div id="' + config.statusId + '"></div>'
+ + '<div id="' + config.eventWindowId + '" style="padding:5px 5px 0 5px;background-color:#eee;border:1px dotted #000;">'
+ + '<p style="margin:0 0 10px 0;"><strong>jPlayer events that have occurred over the past 1 second:</strong>'
+ + '<br />(Backgrounds: <span style="padding:0 5px;background-color:#eee;border:1px dotted #000;">Never occurred</span> <span style="padding:0 5px;background-color:#fff;border:1px dotted #000;">Occurred before</span> <span style="padding:0 5px;background-color:#9f9;border:1px dotted #000;">Occurred</span> <span style="padding:0 5px;background-color:#ff9;border:1px dotted #000;">Multiple occurrences</span> <a href="#" id="' + config.eventResetId + '">reset</a>)</p>';
+
+ // MJP: Would use the next 3 lines for ease, but the events are just slapped on the page.
+ // $.each($.jPlayer.event, function(eventName,eventType) {
+ // structure += '<div id="' + config.eventId[eventType] + '" style="float:left;">' + eventName + '</div>';
+ // });
+
+ var eventStyle = "float:left;margin:0 5px 5px 0;padding:0 5px;border:1px dotted #000;";
+ // MJP: Doing it longhand so order and layout easier to control.
+ structure +=
+ '<div id="' + config.eventId[$.jPlayer.event.ready] + '" style="' + eventStyle + '"></div>'
+ + '<div id="' + config.eventId[$.jPlayer.event.flashreset] + '" style="' + eventStyle + '"></div>'
+ + '<div id="' + config.eventId[$.jPlayer.event.resize] + '" style="' + eventStyle + '"></div>'
+ + '<div id="' + config.eventId[$.jPlayer.event.repeat] + '" style="' + eventStyle + '"></div>'
+ + '<div id="' + config.eventId[$.jPlayer.event.click] + '" style="' + eventStyle + '"></div>'
+ + '<div id="' + config.eventId[$.jPlayer.event.error] + '" style="' + eventStyle + '"></div>'
+ + '<div id="' + config.eventId[$.jPlayer.event.warning] + '" style="' + eventStyle + '"></div>'
+
+ + '<div id="' + config.eventId[$.jPlayer.event.loadstart] + '" style="clear:left;' + eventStyle + '"></div>'
+ + '<div id="' + config.eventId[$.jPlayer.event.progress] + '" style="' + eventStyle + '"></div>'
+ + '<div id="' + config.eventId[$.jPlayer.event.timeupdate] + '" style="' + eventStyle + '"></div>'
+ + '<div id="' + config.eventId[$.jPlayer.event.volumechange] + '" style="' + eventStyle + '"></div>'
+
+ + '<div id="' + config.eventId[$.jPlayer.event.play] + '" style="clear:left;' + eventStyle + '"></div>'
+ + '<div id="' + config.eventId[$.jPlayer.event.pause] + '" style="' + eventStyle + '"></div>'
+ + '<div id="' + config.eventId[$.jPlayer.event.waiting] + '" style="' + eventStyle + '"></div>'
+ + '<div id="' + config.eventId[$.jPlayer.event.playing] + '" style="' + eventStyle + '"></div>'
+ + '<div id="' + config.eventId[$.jPlayer.event.seeking] + '" style="' + eventStyle + '"></div>'
+ + '<div id="' + config.eventId[$.jPlayer.event.seeked] + '" style="' + eventStyle + '"></div>'
+ + '<div id="' + config.eventId[$.jPlayer.event.ended] + '" style="' + eventStyle + '"></div>'
+
+ + '<div id="' + config.eventId[$.jPlayer.event.loadeddata] + '" style="clear:left;' + eventStyle + '"></div>'
+ + '<div id="' + config.eventId[$.jPlayer.event.loadedmetadata] + '" style="' + eventStyle + '"></div>'
+ + '<div id="' + config.eventId[$.jPlayer.event.canplay] + '" style="' + eventStyle + '"></div>'
+ + '<div id="' + config.eventId[$.jPlayer.event.canplaythrough] + '" style="' + eventStyle + '"></div>'
+
+ + '<div id="' + config.eventId[$.jPlayer.event.suspend] + '" style="clear:left;' + eventStyle + '"></div>'
+ + '<div id="' + config.eventId[$.jPlayer.event.abort] + '" style="' + eventStyle + '"></div>'
+ + '<div id="' + config.eventId[$.jPlayer.event.emptied] + '" style="' + eventStyle + '"></div>'
+ + '<div id="' + config.eventId[$.jPlayer.event.stalled] + '" style="' + eventStyle + '"></div>'
+ + '<div id="' + config.eventId[$.jPlayer.event.ratechange] + '" style="' + eventStyle + '"></div>'
+ + '<div id="' + config.eventId[$.jPlayer.event.durationchange] + '" style="' + eventStyle + '"></div>'
+
+ + '<div style="clear:both"></div>';
+
+ // MJP: Would like a check here in case we missed an event.
+
+ // MJP: Check fails, since it is not on the page yet.
+/* $.each($.jPlayer.event, function(eventName,eventType) {
+ if($("#" + config.eventId[eventType])[0] === undefined) {
+ structure += '<div id="' + config.eventId[eventType] + '" style="clear:left;' + eventStyle + '">' + eventName + '</div>';
+ }
+ });
+*/
+ structure +=
+ '</div>'
+ + '<p><a href="#" id="' + config.updateId + '">Update</a> jPlayer Inspector</p>'
+ + '<div id="' + config.configId + '"></div>'
+ + '</div>';
+ $(this).html(structure);
+
+ config.windowJq = $("#" + config.windowId);
+ config.statusJq = $("#" + config.statusId);
+ config.configJq = $("#" + config.configId);
+ config.toggleJq = $("#" + config.toggleId);
+ config.eventResetJq = $("#" + config.eventResetId);
+ config.updateJq = $("#" + config.updateId);
+
+ $.each($.jPlayer.event, function(eventName,eventType) {
+ config.eventJq[eventType] = $("#" + config.eventId[eventType]);
+ config.eventJq[eventType].text(eventName + " (" + config.eventOccurrence[eventType] + ")"); // Sets the text to the event name and (0);
+
+ config.jPlayer.bind(eventType + ".jPlayerInspector", function(e) {
+ config.eventOccurrence[e.type]++;
+ if(config.eventOccurrence[e.type] > 1) {
+ config.eventJq[e.type].css("background-color","#ff9");
+ } else {
+ config.eventJq[e.type].css("background-color","#9f9");
+ }
+ config.eventJq[e.type].text(eventName + " (" + config.eventOccurrence[e.type] + ")");
+ // The timer to handle the color
+ clearTimeout(config.eventTimeout[e.type]);
+ config.eventTimeout[e.type] = setTimeout(function() {
+ config.eventJq[e.type].css("background-color","#fff");
+ }, 1000);
+ // The timer to handle the occurences.
+ setTimeout(function() {
+ config.eventOccurrence[e.type]--;
+ config.eventJq[e.type].text(eventName + " (" + config.eventOccurrence[e.type] + ")");
+ }, 1000);
+ if(config.visible) { // Update the status, if inspector open.
+ $this.jPlayerInspector("updateStatus");
+ }
+ });
+ });
+
+ config.jPlayer.bind($.jPlayer.event.ready + ".jPlayerInspector", function(e) {
+ $this.jPlayerInspector("updateConfig");
+ });
+
+ config.toggleJq.click(function() {
+ if(config.visible) {
+ $(this).text("Show");
+ config.windowJq.hide();
+ config.statusJq.empty();
+ config.configJq.empty();
+ } else {
+ $(this).text("Hide");
+ config.windowJq.show();
+ config.updateJq.click();
+ }
+ config.visible = !config.visible;
+ $(this).blur();
+ return false;
+ });
+
+ config.eventResetJq.click(function() {
+ $.each($.jPlayer.event, function(eventName,eventType) {
+ config.eventJq[eventType].css("background-color","#eee");
+ });
+ $(this).blur();
+ return false;
+ });
+
+ config.updateJq.click(function() {
+ $this.jPlayerInspector("updateStatus");
+ $this.jPlayerInspector("updateConfig");
+ return false;
+ });
+
+ if(!config.visible) {
+ config.windowJq.hide();
+ } else {
+ // config.updateJq.click();
+ }
+
+ $.jPlayerInspector.i++;
+
+ return this;
+ },
+ destroy: function() {
+ $(this).data("jPlayerInspector") && $(this).data("jPlayerInspector").jPlayer.unbind(".jPlayerInspector");
+ $(this).empty();
+ },
+ updateConfig: function() { // This displays information about jPlayer's configuration in inspector
+
+ var jPlayerInfo = "<p>This jPlayer instance is running in your browser where:<br />"
+
+ for(i = 0; i < $(this).data("jPlayerInspector").jPlayer.data("jPlayer").solutions.length; i++) {
+ var solution = $(this).data("jPlayerInspector").jPlayer.data("jPlayer").solutions[i];
+ jPlayerInfo += "&nbsp;jPlayer's <strong>" + solution + "</strong> solution is";
+ if($(this).data("jPlayerInspector").jPlayer.data("jPlayer")[solution].used) {
+ jPlayerInfo += " being <strong>used</strong> and will support:<strong>";
+ for(format in $(this).data("jPlayerInspector").jPlayer.data("jPlayer")[solution].support) {
+ if($(this).data("jPlayerInspector").jPlayer.data("jPlayer")[solution].support[format]) {
+ jPlayerInfo += " " + format;
+ }
+ }
+ jPlayerInfo += "</strong><br />";
+ } else {
+ jPlayerInfo += " <strong>not required</strong><br />";
+ }
+ }
+ jPlayerInfo += "</p>";
+
+ if($(this).data("jPlayerInspector").jPlayer.data("jPlayer").html.active) {
+ if($(this).data("jPlayerInspector").jPlayer.data("jPlayer").flash.active) {
+ jPlayerInfo += "<strong>Problem with jPlayer since both HTML5 and Flash are active.</strong>";
+ } else {
+ jPlayerInfo += "The <strong>HTML5 is active</strong>.";
+ }
+ } else {
+ if($(this).data("jPlayerInspector").jPlayer.data("jPlayer").flash.active) {
+ jPlayerInfo += "The <strong>Flash is active</strong>.";
+ } else {
+ jPlayerInfo += "No solution is currently active. jPlayer needs a setMedia().";
+ }
+ }
+ jPlayerInfo += "</p>";
+
+ var formatType = $(this).data("jPlayerInspector").jPlayer.data("jPlayer").status.formatType;
+ jPlayerInfo += "<p><code>status.formatType = '" + formatType + "'</code><br />";
+ if(formatType) {
+ jPlayerInfo += "<code>Browser canPlay('" + $.jPlayer.prototype.format[formatType].codec + "')</code>";
+ } else {
+ jPlayerInfo += "</p>";
+ }
+
+ jPlayerInfo += "<p><code>status.src = '" + $(this).data("jPlayerInspector").jPlayer.data("jPlayer").status.src + "'</code></p>";
+
+ jPlayerInfo += "<p><code>status.media = {<br />";
+ for(prop in $(this).data("jPlayerInspector").jPlayer.data("jPlayer").status.media) {
+ jPlayerInfo += "&nbsp;" + prop + ": " + $(this).data("jPlayerInspector").jPlayer.data("jPlayer").status.media[prop] + "<br />"; // Some are strings
+ }
+ jPlayerInfo += "};</code></p>"
+
+ + "<p>Raw browser test for HTML5 support. Should equal a function if HTML5 is available.<br />";
+ if($(this).data("jPlayerInspector").jPlayer.data("jPlayer").html.audio.available) {
+ jPlayerInfo += "<code>htmlElement.audio.canPlayType = " + (typeof $(this).data("jPlayerInspector").jPlayer.data("jPlayer").htmlElement.audio.canPlayType) +"</code><br />"
+ }
+ if($(this).data("jPlayerInspector").jPlayer.data("jPlayer").html.video.available) {
+ jPlayerInfo += "<code>htmlElement.video.canPlayType = " + (typeof $(this).data("jPlayerInspector").jPlayer.data("jPlayer").htmlElement.video.canPlayType) +"</code>";
+ }
+ jPlayerInfo += "</p>";
+
+ jPlayerInfo += "<p>This instance is using the constructor options:<br />"
+ + "<code>$('#" + $(this).data("jPlayerInspector").jPlayer.data("jPlayer").internal.self.id + "').jPlayer({<br />"
+
+ + "&nbsp;swfPath: '" + $(this).data("jPlayerInspector").jPlayer.jPlayer("option", "swfPath") + "',<br />"
+
+ + "&nbsp;solution: '" + $(this).data("jPlayerInspector").jPlayer.jPlayer("option", "solution") + "',<br />"
+
+ + "&nbsp;supplied: '" + $(this).data("jPlayerInspector").jPlayer.jPlayer("option", "supplied") + "',<br />"
+
+ + "&nbsp;preload: '" + $(this).data("jPlayerInspector").jPlayer.jPlayer("option", "preload") + "',<br />"
+
+ + "&nbsp;volume: " + $(this).data("jPlayerInspector").jPlayer.jPlayer("option", "volume") + ",<br />"
+
+ + "&nbsp;muted: " + $(this).data("jPlayerInspector").jPlayer.jPlayer("option", "muted") + ",<br />"
+
+ + "&nbsp;backgroundColor: '" + $(this).data("jPlayerInspector").jPlayer.jPlayer("option", "backgroundColor") + "',<br />"
+
+ + "&nbsp;cssSelectorAncestor: '" + $(this).data("jPlayerInspector").jPlayer.jPlayer("option", "cssSelectorAncestor") + "',<br />"
+
+ + "&nbsp;cssSelector: {";
+
+ var cssSelector = $(this).data("jPlayerInspector").jPlayer.jPlayer("option", "cssSelector");
+ for(prop in cssSelector) {
+
+ // jPlayerInfo += "<br />&nbsp;&nbsp;" + prop + ": '" + cssSelector[prop] + "'," // This works too of course, but want to use option method for deep keys.
+ jPlayerInfo += "<br />&nbsp;&nbsp;" + prop + ": '" + $(this).data("jPlayerInspector").jPlayer.jPlayer("option", "cssSelector." + prop) + "',"
+ }
+
+ jPlayerInfo = jPlayerInfo.slice(0, -1); // Because the sloppy comma was bugging me.
+
+ jPlayerInfo += "<br />&nbsp;},<br />"
+
+ + "&nbsp;errorAlerts: " + $(this).data("jPlayerInspector").jPlayer.jPlayer("option", "errorAlerts") + ",<br />"
+
+ + "&nbsp;warningAlerts: " + $(this).data("jPlayerInspector").jPlayer.jPlayer("option", "warningAlerts") + "<br />"
+
+ + "});</code></p>";
+ $(this).data("jPlayerInspector").configJq.html(jPlayerInfo);
+ return this;
+ },
+ updateStatus: function() { // This displays information about jPlayer's status in the inspector
+ $(this).data("jPlayerInspector").statusJq.html(
+ "<p>jPlayer is " +
+ ($(this).data("jPlayerInspector").jPlayer.data("jPlayer").status.paused ? "paused" : "playing") +
+ " at time: " + Math.floor($(this).data("jPlayerInspector").jPlayer.data("jPlayer").status.currentTime*10)/10 + "s." +
+ " (d: " + Math.floor($(this).data("jPlayerInspector").jPlayer.data("jPlayer").status.duration*10)/10 + "s" +
+ ", sp: " + Math.floor($(this).data("jPlayerInspector").jPlayer.data("jPlayer").status.seekPercent) + "%" +
+ ", cpr: " + Math.floor($(this).data("jPlayerInspector").jPlayer.data("jPlayer").status.currentPercentRelative) + "%" +
+ ", cpa: " + Math.floor($(this).data("jPlayerInspector").jPlayer.data("jPlayer").status.currentPercentAbsolute) + "%)</p>"
+ );
+ return this;
+ }
+ };
+ $.fn.jPlayerInspector = function( method ) {
+ // Method calling logic
+ if ( methods[method] ) {
+ return methods[ method ].apply( this, Array.prototype.slice.call( arguments, 1 ));
+ } else if ( typeof method === 'object' || ! method ) {
+ return methods.init.apply( this, arguments );
+ } else {
+ $.error( 'Method ' + method + ' does not exist on jQuery.jPlayerInspector' );
+ }
+ };
+})(jQuery);
diff --git a/apps/media/js/jQuery.jPlayer.2.1.0.source/happyworm/jPlayer/JplayerEvent.as b/apps/media/js/jQuery.jPlayer.2.1.0.source/happyworm/jPlayer/JplayerEvent.as
new file mode 100644
index 00000000000..addb97a7ae4
--- /dev/null
+++ b/apps/media/js/jQuery.jPlayer.2.1.0.source/happyworm/jPlayer/JplayerEvent.as
@@ -0,0 +1,69 @@
+/*
+ * jPlayer Plugin for jQuery JavaScript Library
+ * http://www.happyworm.com/jquery/jplayer
+ *
+ * Copyright (c) 2009 - 2011 Happyworm Ltd
+ * Dual licensed under the MIT and GPL licenses.
+ * - http://www.opensource.org/licenses/mit-license.php
+ * - http://www.gnu.org/copyleft/gpl.html
+ *
+ * Author: Mark J Panaghiston
+ * Date: 8th August 2011
+ */
+
+package happyworm.jPlayer {
+ import flash.events.Event;
+
+ public class JplayerEvent extends Event {
+
+ // The event strings must match those in the JavaScript's $.jPlayer.event object
+
+ public static const JPLAYER_READY:String = "jPlayer_ready";
+ public static const JPLAYER_FLASHRESET:String = "jPlayer_flashreset"; // Handled in JavaScript
+ public static const JPLAYER_RESIZE:String = "jPlayer_resize"; // Handled in JavaScript
+ public static const JPLAYER_REPEAT:String = "jPlayer_repeat"; // Handled in JavaScript
+ public static const JPLAYER_CLICK:String = "jPlayer_click";
+ public static const JPLAYER_ERROR:String = "jPlayer_error";
+ public static const JPLAYER_WARNING:String = "jPlayer_warning"; // Currently not used by the flash solution
+
+ public static const JPLAYER_LOADSTART:String = "jPlayer_loadstart";
+ public static const JPLAYER_PROGRESS:String = "jPlayer_progress";
+ public static const JPLAYER_SUSPEND:String = "jPlayer_suspend"; // Not implemented
+ public static const JPLAYER_ABORT:String = "jPlayer_abort"; // Not implemented
+ public static const JPLAYER_EMPTIED:String = "jPlayer_emptied"; // Not implemented
+ public static const JPLAYER_STALLED:String = "jPlayer_stalled"; // Not implemented
+ public static const JPLAYER_PLAY:String = "jPlayer_play";
+ public static const JPLAYER_PAUSE:String = "jPlayer_pause";
+ public static const JPLAYER_LOADEDMETADATA:String = "jPlayer_loadedmetadata"; // MP3 has no equivilent
+ public static const JPLAYER_LOADEDDATA:String = "jPlayer_loadeddata"; // Not implemented
+ public static const JPLAYER_WAITING:String = "jPlayer_waiting"; // Not implemented
+ public static const JPLAYER_PLAYING:String = "jPlayer_playing"; // Not implemented
+ public static const JPLAYER_CANPLAY:String = "jPlayer_canplay"; // Not implemented
+ public static const JPLAYER_CANPLAYTHROUGH:String = "jPlayer_canplaythrough"; // Not implemented
+ public static const JPLAYER_SEEKING:String = "jPlayer_seeking";
+ public static const JPLAYER_SEEKED:String = "jPlayer_seeked";
+ public static const JPLAYER_TIMEUPDATE:String = "jPlayer_timeupdate";
+ public static const JPLAYER_ENDED:String = "jPlayer_ended";
+ public static const JPLAYER_RATECHANGE:String = "jPlayer_ratechange"; // Not implemented
+ public static const JPLAYER_DURATIONCHANGE:String = "jPlayer_durationchange"; // Not implemented
+ public static const JPLAYER_VOLUMECHANGE:String = "jPlayer_volumechange"; // See JavaScript
+
+ // Events used internal to jPlayer's Flash.
+ public static const DEBUG_MSG:String = "debug_msg";
+
+ public var data:JplayerStatus;
+ public var msg:String = ""
+
+ public function JplayerEvent(type:String, data:JplayerStatus, msg:String = "", bubbles:Boolean = false, cancelable:Boolean = false) {
+ super(type, bubbles, cancelable);
+ this.data = data;
+ this.msg = msg;
+ }
+ public override function clone():Event {
+ return new JplayerEvent(type, data, msg, bubbles, cancelable);
+ }
+ public override function toString():String {
+ return formatToString("JplayerEvent", "type", "bubbles", "cancelable", "eventPhase", "data", "msg");
+ }
+ }
+} \ No newline at end of file
diff --git a/apps/media/js/jQuery.jPlayer.2.1.0.source/happyworm/jPlayer/JplayerMp3.as b/apps/media/js/jQuery.jPlayer.2.1.0.source/happyworm/jPlayer/JplayerMp3.as
new file mode 100644
index 00000000000..8c51d5b7633
--- /dev/null
+++ b/apps/media/js/jQuery.jPlayer.2.1.0.source/happyworm/jPlayer/JplayerMp3.as
@@ -0,0 +1,328 @@
+/*
+ * jPlayer Plugin for jQuery JavaScript Library
+ * http://www.happyworm.com/jquery/jplayer
+ *
+ * Copyright (c) 2009 - 2011 Happyworm Ltd
+ * Dual licensed under the MIT and GPL licenses.
+ * - http://www.opensource.org/licenses/mit-license.php
+ * - http://www.gnu.org/copyleft/gpl.html
+ *
+ * Author: Mark J Panaghiston
+ * Date: 1st September 2011
+ */
+
+package happyworm.jPlayer {
+ import flash.display.Sprite;
+
+ import flash.media.Sound;
+ import flash.media.SoundChannel;
+ import flash.media.SoundLoaderContext;
+ import flash.media.SoundTransform;
+ import flash.net.URLRequest;
+ import flash.utils.Timer;
+ import flash.errors.IOError;
+ import flash.events.*;
+
+ public class JplayerMp3 extends Sprite {
+ private var mySound:Sound = new Sound();
+ private var myChannel:SoundChannel = new SoundChannel();
+ private var myContext:SoundLoaderContext = new SoundLoaderContext(3000, false);
+ private var myTransform:SoundTransform = new SoundTransform();
+ private var myRequest:URLRequest = new URLRequest();
+
+ private var timeUpdateTimer:Timer = new Timer(250, 0); // Matched to HTML event freq
+ private var progressTimer:Timer = new Timer(250, 0); // Matched to HTML event freq
+ private var seekingTimer:Timer = new Timer(100, 0); // Internal: How often seeking is checked to see if it is over.
+
+ public var myStatus:JplayerStatus = new JplayerStatus();
+
+ public function JplayerMp3(volume:Number) {
+ timeUpdateTimer.addEventListener(TimerEvent.TIMER, timeUpdateHandler);
+ progressTimer.addEventListener(TimerEvent.TIMER, progressHandler);
+ seekingTimer.addEventListener(TimerEvent.TIMER, seekingHandler);
+ setVolume(volume);
+ }
+ public function setFile(src:String):void {
+ this.dispatchEvent(new JplayerEvent(JplayerEvent.DEBUG_MSG, myStatus, "setFile: " + src));
+ if(myStatus.isPlaying) {
+ myChannel.stop();
+ progressUpdates(false);
+ timeUpdates(false);
+ }
+ try {
+ mySound.close();
+ } catch (err:IOError) {
+ // Occurs if the file is either yet to be opened or has finished downloading.
+ }
+ mySound = null;
+ mySound = new Sound();
+ mySound.addEventListener(IOErrorEvent.IO_ERROR, errorHandler);
+ mySound.addEventListener(Event.OPEN, loadOpen);
+ mySound.addEventListener(Event.COMPLETE, loadComplete);
+ myRequest = new URLRequest(src);
+ myStatus.reset();
+ myStatus.src = src;
+ myStatus.srcSet = true;
+ timeUpdateEvent();
+ }
+ public function clearFile():void {
+ setFile("");
+ myStatus.srcSet = false;
+ }
+ private function errorHandler(err:IOErrorEvent):void {
+ // MP3 player needs to stop progress and timeupdate events as they are started before the error occurs.
+ // NB: The MP4 player works differently and the error occurs before they are started.
+ progressUpdates(false);
+ timeUpdates(false);
+ myStatus.error(); // Resets status except the src, and it sets srcError property.
+ this.dispatchEvent(new JplayerEvent(JplayerEvent.JPLAYER_ERROR, myStatus));
+ }
+ private function loadOpen(e:Event):void {
+ this.dispatchEvent(new JplayerEvent(JplayerEvent.DEBUG_MSG, myStatus, "loadOpen:"));
+ myStatus.loading();
+ if(myStatus.playOnLoad) {
+ myStatus.playOnLoad = false; // Capture the flag
+ this.dispatchEvent(new JplayerEvent(JplayerEvent.JPLAYER_LOADSTART, myStatus)); // So loadstart event happens before play event occurs.
+ play();
+ } else {
+ this.dispatchEvent(new JplayerEvent(JplayerEvent.JPLAYER_LOADSTART, myStatus));
+ pause();
+ }
+ progressUpdates(true);
+ }
+ private function loadComplete(e:Event):void {
+ this.dispatchEvent(new JplayerEvent(JplayerEvent.DEBUG_MSG, myStatus, "loadComplete:"));
+ myStatus.loaded();
+ progressUpdates(false);
+ progressEvent();
+ }
+ private function soundCompleteHandler(e:Event):void {
+ myStatus.pausePosition = 0;
+ myStatus.isPlaying = false;
+ timeUpdates(false);
+ timeUpdateEvent();
+ this.dispatchEvent(new JplayerEvent(JplayerEvent.JPLAYER_ENDED, myStatus));
+ }
+ private function progressUpdates(active:Boolean):void {
+ // Using a timer rather than Flash's load progress event, because that event gave data at about 200Hz. The 10Hz timer is closer to HTML5 norm.
+ if(active) {
+ progressTimer.start();
+ } else {
+ progressTimer.stop();
+ }
+ }
+ private function progressHandler(e:TimerEvent):void {
+ progressEvent();
+ }
+ private function progressEvent():void {
+ this.dispatchEvent(new JplayerEvent(JplayerEvent.DEBUG_MSG, myStatus, "progressEvent:"));
+ updateStatusValues();
+ this.dispatchEvent(new JplayerEvent(JplayerEvent.JPLAYER_PROGRESS, myStatus));
+ }
+ private function timeUpdates(active:Boolean):void {
+ if(active) {
+ timeUpdateTimer.start();
+ } else {
+ timeUpdateTimer.stop();
+ }
+ }
+ private function timeUpdateHandler(e:TimerEvent):void {
+ timeUpdateEvent();
+ }
+ private function timeUpdateEvent():void {
+ updateStatusValues();
+ this.dispatchEvent(new JplayerEvent(JplayerEvent.JPLAYER_TIMEUPDATE, myStatus));
+ }
+ private function seeking(active:Boolean):void {
+ if(active) {
+ if(!myStatus.isSeeking) {
+ seekingEvent();
+ seekingTimer.start();
+ }
+ } else {
+ seekingTimer.stop();
+ }
+ }
+ private function seekingHandler(e:TimerEvent):void {
+ if(myStatus.pausePosition <= getDuration()) {
+ seekedEvent();
+ seeking(false);
+ if(myStatus.playOnSeek) {
+ myStatus.playOnSeek = false; // Capture the flag.
+ play();
+ }
+ } else if(myStatus.isLoaded && (myStatus.pausePosition > getDuration())) {
+ // Illegal seek time
+ seeking(false);
+ seekedEvent();
+ pause(0);
+ }
+ }
+ private function seekingEvent():void {
+ myStatus.isSeeking = true;
+ updateStatusValues();
+ this.dispatchEvent(new JplayerEvent(JplayerEvent.JPLAYER_SEEKING, myStatus));
+ }
+ private function seekedEvent():void {
+ myStatus.isSeeking = false;
+ updateStatusValues();
+ this.dispatchEvent(new JplayerEvent(JplayerEvent.JPLAYER_SEEKED, myStatus));
+ }
+ public function load():Boolean {
+ if(myStatus.loadRequired()) {
+ myStatus.startingDownload();
+ mySound.load(myRequest, myContext);
+ return true;
+ } else {
+ return false;
+ }
+ }
+ public function play(time:Number = NaN):Boolean {
+ var wasPlaying:Boolean = myStatus.isPlaying;
+
+ if(!isNaN(time) && myStatus.srcSet) {
+ if(myStatus.isPlaying) {
+ myChannel.stop();
+ myStatus.isPlaying = false;
+ }
+ myStatus.pausePosition = time;
+ }
+
+ if(myStatus.isStartingDownload) {
+ myStatus.playOnLoad = true; // Raise flag, captured in loadOpen()
+ return true;
+ } else if(myStatus.loadRequired()) {
+ myStatus.playOnLoad = true; // Raise flag, captured in loadOpen()
+ return load();
+ } else if((myStatus.isLoading || myStatus.isLoaded) && !myStatus.isPlaying) {
+ if(myStatus.isLoaded && myStatus.pausePosition > getDuration()) { // The time is invalid, ie., past the end.
+ myStatus.pausePosition = 0;
+ timeUpdates(false);
+ timeUpdateEvent();
+ if(wasPlaying) { // For when playing and then get a play(huge)
+ this.dispatchEvent(new JplayerEvent(JplayerEvent.JPLAYER_PAUSE, myStatus));
+ }
+ } else if(myStatus.pausePosition > getDuration()) {
+ myStatus.playOnSeek = true;
+ seeking(true);
+ } else {
+ myStatus.isPlaying = true; // Set immediately before playing. Could affects events.
+ myChannel = mySound.play(myStatus.pausePosition);
+ myChannel.soundTransform = myTransform;
+ myChannel.addEventListener(Event.SOUND_COMPLETE, soundCompleteHandler);
+ timeUpdates(true);
+ if(!wasPlaying) {
+ this.dispatchEvent(new JplayerEvent(JplayerEvent.JPLAYER_PLAY, myStatus));
+ }
+ }
+ return true;
+ } else {
+ return false;
+ }
+ }
+ public function pause(time:Number = NaN):Boolean {
+ myStatus.playOnLoad = false; // Reset flag in case load/play issued immediately before this command, ie., before loadOpen() event.
+ myStatus.playOnSeek = false; // Reset flag in case play(time) issued before the command and is still seeking to time set.
+
+ var wasPlaying:Boolean = myStatus.isPlaying;
+
+ // To avoid possible loops with timeupdate and pause(time). A pause() does not have the problem.
+ var alreadyPausedAtTime:Boolean = false;
+ if(!isNaN(time) && myStatus.pausePosition == time) {
+ alreadyPausedAtTime = true;
+ }
+
+ if(myStatus.isPlaying) {
+ myStatus.isPlaying = false;
+ myChannel.stop();
+ if(myChannel.position > 0) { // Required otherwise a fast play then pause causes myChannel.position to equal zero and not the correct value. ie., When it happens leave pausePosition alone.
+ myStatus.pausePosition = myChannel.position;
+ }
+ }
+
+ if(!isNaN(time) && myStatus.srcSet) {
+ myStatus.pausePosition = time;
+ }
+
+ if(wasPlaying) {
+ this.dispatchEvent(new JplayerEvent(JplayerEvent.JPLAYER_PAUSE, myStatus));
+ }
+
+ if(myStatus.isStartingDownload) {
+ return true;
+ } else if(myStatus.loadRequired()) {
+ if(time > 0) { // We do not want the stop() command, which does pause(0), causing a load operation.
+ return load();
+ } else {
+ return true; // Technically the pause(0) succeeded. ie., It did nothing, since nothing was required.
+ }
+ } else if(myStatus.isLoading || myStatus.isLoaded) {
+ if(myStatus.isLoaded && myStatus.pausePosition > getDuration()) { // The time is invalid, ie., past the end.
+ myStatus.pausePosition = 0;
+ } else if(myStatus.pausePosition > getDuration()) {
+ seeking(true);
+ }
+ timeUpdates(false);
+ // Need to be careful with timeupdate event, otherwise a pause in a timeupdate event can cause a loop.
+ // Neither pause() nor pause(time) will cause a timeupdate loop.
+ if(wasPlaying || !isNaN(time) && !alreadyPausedAtTime) {
+ timeUpdateEvent();
+ }
+ return true;
+ } else {
+ return false;
+ }
+ }
+ public function playHead(percent:Number):Boolean {
+ var time:Number = percent * getDuration() / 100;
+ if(myStatus.isPlaying || myStatus.playOnLoad || myStatus.playOnSeek) {
+ return play(time);
+ } else {
+ return pause(time);
+ }
+ }
+ public function setVolume(v:Number):void {
+ myStatus.volume = v;
+ myTransform.volume = v;
+ myChannel.soundTransform = myTransform;
+ }
+ private function updateStatusValues():void {
+ myStatus.seekPercent = 100 * getLoadRatio();
+ myStatus.currentTime = getCurrentTime();
+ myStatus.currentPercentRelative = 100 * getCurrentRatioRel();
+ myStatus.currentPercentAbsolute = 100 * getCurrentRatioAbs();
+ myStatus.duration = getDuration();
+ }
+ public function getLoadRatio():Number {
+ if((myStatus.isLoading || myStatus.isLoaded) && mySound.bytesTotal > 0) {
+ return mySound.bytesLoaded / mySound.bytesTotal;
+ } else {
+ return 0;
+ }
+ }
+ public function getDuration():Number {
+ if(mySound.length > 0) {
+ return mySound.length;
+ } else {
+ return 0;
+ }
+ }
+ public function getCurrentTime():Number {
+ if(myStatus.isPlaying) {
+ return myChannel.position;
+ } else {
+ return myStatus.pausePosition;
+ }
+ }
+ public function getCurrentRatioRel():Number {
+ if((getDuration() > 0) && (getCurrentTime() <= getDuration())) {
+ return getCurrentTime() / getDuration();
+ } else {
+ return 0;
+ }
+ }
+ public function getCurrentRatioAbs():Number {
+ return getCurrentRatioRel() * getLoadRatio();
+ }
+ }
+}
diff --git a/apps/media/js/jQuery.jPlayer.2.1.0.source/happyworm/jPlayer/JplayerMp4.as b/apps/media/js/jQuery.jPlayer.2.1.0.source/happyworm/jPlayer/JplayerMp4.as
new file mode 100644
index 00000000000..dcdc0655d0d
--- /dev/null
+++ b/apps/media/js/jQuery.jPlayer.2.1.0.source/happyworm/jPlayer/JplayerMp4.as
@@ -0,0 +1,413 @@
+/*
+ * jPlayer Plugin for jQuery JavaScript Library
+ * http://www.happyworm.com/jquery/jplayer
+ *
+ * Copyright (c) 2009 - 2011 Happyworm Ltd
+ * Dual licensed under the MIT and GPL licenses.
+ * - http://www.opensource.org/licenses/mit-license.php
+ * - http://www.gnu.org/copyleft/gpl.html
+ *
+ * Author: Mark J Panaghiston
+ * Date: 7th August 2011
+ */
+
+package happyworm.jPlayer {
+ import flash.display.Sprite;
+
+ import flash.media.Video;
+ import flash.media.SoundTransform;
+
+ import flash.net.NetConnection;
+ import flash.net.NetStream;
+
+ import flash.utils.Timer;
+
+ import flash.events.NetStatusEvent;
+ import flash.events.SecurityErrorEvent;
+ import flash.events.TimerEvent;
+
+ public class JplayerMp4 extends Sprite {
+
+ public var myVideo:Video = new Video();
+ private var myConnection:NetConnection;
+ private var myStream:NetStream;
+
+ private var myTransform:SoundTransform = new SoundTransform();
+
+ public var myStatus:JplayerStatus = new JplayerStatus();
+
+ private var timeUpdateTimer:Timer = new Timer(250, 0); // Matched to HTML event freq
+ private var progressTimer:Timer = new Timer(250, 0); // Matched to HTML event freq
+ private var seekingTimer:Timer = new Timer(100, 0); // Internal: How often seeking is checked to see if it is over.
+
+ public function JplayerMp4(volume:Number) {
+ myConnection = new NetConnection();
+ myConnection.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
+ myConnection.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler);
+ myVideo.smoothing = true;
+ this.addChild(myVideo);
+
+ timeUpdateTimer.addEventListener(TimerEvent.TIMER, timeUpdateHandler);
+ progressTimer.addEventListener(TimerEvent.TIMER, progressHandler);
+ seekingTimer.addEventListener(TimerEvent.TIMER, seekingHandler);
+
+ myStatus.volume = volume;
+ }
+ private function progressUpdates(active:Boolean):void {
+ if(active) {
+ progressTimer.start();
+ } else {
+ progressTimer.stop();
+ }
+ }
+ private function progressHandler(e:TimerEvent):void {
+ if(myStatus.isLoading) {
+ if(getLoadRatio() == 1) { // Close as can get to a loadComplete event since client.onPlayStatus only works with FMS
+ this.dispatchEvent(new JplayerEvent(JplayerEvent.DEBUG_MSG, myStatus, "progressHandler: loadComplete"));
+ myStatus.loaded();
+ progressUpdates(false);
+ }
+ }
+ progressEvent();
+ }
+ private function progressEvent():void {
+ this.dispatchEvent(new JplayerEvent(JplayerEvent.DEBUG_MSG, myStatus, "progressEvent:"));
+ updateStatusValues();
+ this.dispatchEvent(new JplayerEvent(JplayerEvent.JPLAYER_PROGRESS, myStatus));
+ }
+ private function timeUpdates(active:Boolean):void {
+ if(active) {
+ timeUpdateTimer.start();
+ } else {
+ timeUpdateTimer.stop();
+ }
+ }
+ private function timeUpdateHandler(e:TimerEvent):void {
+ timeUpdateEvent();
+ }
+ private function timeUpdateEvent():void {
+ updateStatusValues();
+ this.dispatchEvent(new JplayerEvent(JplayerEvent.JPLAYER_TIMEUPDATE, myStatus));
+ }
+ private function seeking(active:Boolean):void {
+ if(active) {
+ if(!myStatus.isSeeking) {
+ seekingEvent();
+ }
+ seekingTimer.start();
+ } else {
+ if(myStatus.isSeeking) {
+ seekedEvent();
+ }
+ seekingTimer.stop();
+ }
+ }
+ private function seekingHandler(e:TimerEvent):void {
+ if(getSeekTimeRatio() <= getLoadRatio()) {
+ seeking(false);
+ if(myStatus.playOnSeek) {
+ myStatus.playOnSeek = false; // Capture the flag.
+ play(myStatus.pausePosition); // Must pass time or the seek time is never set.
+ } else {
+ pause(myStatus.pausePosition); // Must pass time or the stream.time is read.
+ }
+ } else if(myStatus.metaDataReady && myStatus.pausePosition > myStatus.duration) {
+ // Illegal seek time
+ seeking(false);
+ pause(0);
+ }
+ }
+ private function seekingEvent():void {
+ myStatus.isSeeking = true;
+ updateStatusValues();
+ this.dispatchEvent(new JplayerEvent(JplayerEvent.JPLAYER_SEEKING, myStatus));
+ }
+ private function seekedEvent():void {
+ myStatus.isSeeking = false;
+ updateStatusValues();
+ this.dispatchEvent(new JplayerEvent(JplayerEvent.JPLAYER_SEEKED, myStatus));
+ }
+ private function netStatusHandler(e:NetStatusEvent):void {
+ this.dispatchEvent(new JplayerEvent(JplayerEvent.DEBUG_MSG, myStatus, "netStatusHandler: '" + e.info.code + "'"));
+ switch(e.info.code) {
+ case "NetConnection.Connect.Success":
+ connectStream();
+ break;
+ case "NetStream.Play.Start":
+ // This event code occurs once, when the media is opened. Equiv to loadOpen() in mp3 player.
+ myStatus.loading();
+ this.dispatchEvent(new JplayerEvent(JplayerEvent.JPLAYER_LOADSTART, myStatus));
+ progressUpdates(true);
+ // See onMetaDataHandler() for other condition, since duration is vital.
+ break;
+ case "NetStream.Play.Stop":
+ this.dispatchEvent(new JplayerEvent(JplayerEvent.DEBUG_MSG, myStatus, "NetStream.Play.Stop: getDuration() - getCurrentTime() = " + (getDuration() - getCurrentTime())));
+
+ // Check if media is at the end (or close) otherwise this was due to download bandwidth stopping playback. ie., Download is not fast enough.
+ if(Math.abs(getDuration() - getCurrentTime()) < 150) { // Testing found 150ms worked best for M4A files, where playHead(99.9) caused a stuck state due to firing with ~116ms left to play.
+ endedEvent();
+ }
+ break;
+ case "NetStream.Seek.InvalidTime":
+ // Used for capturing invalid set times and clicks on the end of the progress bar.
+ endedEvent();
+ break;
+ case "NetStream.Play.StreamNotFound":
+ myStatus.error(); // Resets status except the src, and it sets srcError property.
+ this.dispatchEvent(new JplayerEvent(JplayerEvent.JPLAYER_ERROR, myStatus));
+ break;
+ }
+ // "NetStream.Seek.Notify" event code is not very useful. It occurs after every seek(t) command issued and does not appear to wait for the media to be ready.
+ }
+ private function endedEvent():void {
+ var wasPlaying:Boolean = myStatus.isPlaying;
+ pause(0);
+ timeUpdates(false);
+ timeUpdateEvent();
+ if(wasPlaying) {
+ this.dispatchEvent(new JplayerEvent(JplayerEvent.JPLAYER_ENDED, myStatus));
+ }
+ }
+ private function securityErrorHandler(event:SecurityErrorEvent):void {
+ this.dispatchEvent(new JplayerEvent(JplayerEvent.DEBUG_MSG, myStatus, "securityErrorHandler."));
+ }
+ private function connectStream():void {
+ this.dispatchEvent(new JplayerEvent(JplayerEvent.DEBUG_MSG, myStatus, "connectStream."));
+ var customClient:Object = new Object();
+ customClient.onMetaData = onMetaDataHandler;
+ // customClient.onPlayStatus = onPlayStatusHandler; // According to the forums and my tests, onPlayStatus only works with FMS (Flash Media Server).
+ myStream = null;
+ myStream = new NetStream(myConnection);
+ myStream.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
+ myStream.client = customClient;
+ myVideo.attachNetStream(myStream);
+ setVolume(myStatus.volume);
+ myStream.play(myStatus.src);
+ }
+ public function setFile(src:String):void {
+ if(myStream != null) {
+ myStream.close();
+ }
+ myVideo.clear();
+ progressUpdates(false);
+ timeUpdates(false);
+
+ myStatus.reset();
+ myStatus.src = src;
+ myStatus.srcSet = true;
+ timeUpdateEvent();
+ }
+ public function clearFile():void {
+ setFile("");
+ myStatus.srcSet = false;
+ }
+ public function load():Boolean {
+ if(myStatus.loadRequired()) {
+ myStatus.startingDownload();
+ myConnection.connect(null);
+ return true;
+ } else {
+ return false;
+ }
+ }
+ public function play(time:Number = NaN):Boolean {
+ var wasPlaying:Boolean = myStatus.isPlaying;
+
+ if(!isNaN(time) && myStatus.srcSet) {
+ if(myStatus.isPlaying) {
+ myStream.pause();
+ myStatus.isPlaying = false;
+ }
+ myStatus.pausePosition = time;
+ }
+
+ if(myStatus.isStartingDownload) {
+ myStatus.playOnLoad = true; // Raise flag, captured in onMetaDataHandler()
+ return true;
+ } else if(myStatus.loadRequired()) {
+ myStatus.playOnLoad = true; // Raise flag, captured in onMetaDataHandler()
+ return load();
+ } else if((myStatus.isLoading || myStatus.isLoaded) && !myStatus.isPlaying) {
+ if(myStatus.metaDataReady && myStatus.pausePosition > myStatus.duration) { // The time is invalid, ie., past the end.
+ myStream.pause(); // Since it is playing by default at this point.
+ myStatus.pausePosition = 0;
+ myStream.seek(0);
+ timeUpdates(false);
+ timeUpdateEvent();
+ if(wasPlaying) { // For when playing and then get a play(huge)
+ this.dispatchEvent(new JplayerEvent(JplayerEvent.JPLAYER_PAUSE, myStatus));
+ }
+ } else if(getSeekTimeRatio() > getLoadRatio()) { // Use an estimate based on the downloaded amount
+ myStatus.playOnSeek = true;
+ seeking(true);
+ myStream.pause(); // Since it is playing by default at this point.
+ } else {
+ if(!isNaN(time)) { // Avoid using seek() when it is already correct.
+ myStream.seek(myStatus.pausePosition/1000); // Since time is in ms and seek() takes seconds
+ }
+ myStatus.isPlaying = true; // Set immediately before playing. Could affects events.
+ myStream.resume();
+ timeUpdates(true);
+ if(!wasPlaying) {
+ this.dispatchEvent(new JplayerEvent(JplayerEvent.JPLAYER_PLAY, myStatus));
+ }
+ }
+ return true;
+ } else {
+ return false;
+ }
+ }
+ public function pause(time:Number = NaN):Boolean {
+ myStatus.playOnLoad = false; // Reset flag in case load/play issued immediately before this command, ie., before onMetadata() event.
+ myStatus.playOnSeek = false; // Reset flag in case play(time) issued before the command and is still seeking to time set.
+
+ var wasPlaying:Boolean = myStatus.isPlaying;
+
+ // To avoid possible loops with timeupdate and pause(time). A pause() does not have the problem.
+ var alreadyPausedAtTime:Boolean = false;
+ if(!isNaN(time) && myStatus.pausePosition == time) {
+ alreadyPausedAtTime = true;
+ }
+
+ // Need to wait for metadata to load before ever issuing a pause. The metadata handler will call this function if needed, when ready.
+ if(myStream != null && myStatus.metaDataReady) { // myStream is a null until the 1st media is loaded. ie., The 1st ever setMedia being followed by a pause() or pause(t).
+ myStream.pause();
+ }
+ if(myStatus.isPlaying) {
+ myStatus.isPlaying = false;
+ myStatus.pausePosition = myStream.time * 1000;
+ }
+
+ if(!isNaN(time) && myStatus.srcSet) {
+ myStatus.pausePosition = time;
+ }
+
+ if(wasPlaying) {
+ this.dispatchEvent(new JplayerEvent(JplayerEvent.JPLAYER_PAUSE, myStatus));
+ }
+
+ if(myStatus.isStartingDownload) {
+ return true;
+ } else if(myStatus.loadRequired()) {
+ if(time > 0) { // We do not want the stop() command, which does pause(0), causing a load operation.
+ return load();
+ } else {
+ return true; // Technically the pause(0) succeeded. ie., It did nothing, since nothing was required.
+ }
+ } else if(myStatus.isLoading || myStatus.isLoaded) {
+ if(myStatus.metaDataReady && myStatus.pausePosition > myStatus.duration) { // The time is invalid, ie., past the end.
+ myStatus.pausePosition = 0;
+ myStream.seek(0);
+ seekedEvent(); // Deals with seeking effect when using setMedia() then pause(huge). NB: There is no preceeding seeking event.
+ } else if(!isNaN(time)) {
+ if(getSeekTimeRatio() > getLoadRatio()) { // Use an estimate based on the downloaded amount
+ seeking(true);
+ } else {
+ if(myStatus.metaDataReady) { // Otherwise seek(0) will stop the metadata loading.
+ myStream.seek(myStatus.pausePosition/1000);
+ }
+ }
+ }
+ timeUpdates(false);
+ // Need to be careful with timeupdate event, otherwise a pause in a timeupdate event can cause a loop.
+ // Neither pause() nor pause(time) will cause a timeupdate loop.
+ if(wasPlaying || !isNaN(time) && !alreadyPausedAtTime) {
+ timeUpdateEvent();
+ }
+ return true;
+ } else {
+ return false;
+ }
+ }
+ public function playHead(percent:Number):Boolean {
+ var time:Number = percent * getDuration() * getLoadRatio() / 100;
+ if(myStatus.isPlaying || myStatus.playOnLoad || myStatus.playOnSeek) {
+ return play(time);
+ } else {
+ return pause(time);
+ }
+ }
+ public function setVolume(v:Number):void {
+ myStatus.volume = v;
+ myTransform.volume = v;
+ if(myStream != null) {
+ myStream.soundTransform = myTransform;
+ }
+ }
+ private function updateStatusValues():void {
+ myStatus.seekPercent = 100 * getLoadRatio();
+ myStatus.currentTime = getCurrentTime();
+ myStatus.currentPercentRelative = 100 * getCurrentRatioRel();
+ myStatus.currentPercentAbsolute = 100 * getCurrentRatioAbs();
+ myStatus.duration = getDuration();
+ }
+ public function getLoadRatio():Number {
+ if((myStatus.isLoading || myStatus.isLoaded) && myStream.bytesTotal > 0) {
+ return myStream.bytesLoaded / myStream.bytesTotal;
+ } else {
+ return 0;
+ }
+ }
+ public function getDuration():Number {
+ return myStatus.duration; // Set from meta data.
+ }
+ public function getCurrentTime():Number {
+ if(myStatus.isPlaying) {
+ return myStream.time * 1000;
+ } else {
+ return myStatus.pausePosition;
+ }
+ }
+ public function getCurrentRatioRel():Number {
+ if((getLoadRatio() > 0) && (getCurrentRatioAbs() <= getLoadRatio())) {
+ return getCurrentRatioAbs() / getLoadRatio();
+ } else {
+ return 0;
+ }
+ }
+ public function getCurrentRatioAbs():Number {
+ if(getDuration() > 0) {
+ return getCurrentTime() / getDuration();
+ } else {
+ return 0;
+ }
+ }
+ public function getSeekTimeRatio():Number {
+ if(getDuration() > 0) {
+ return myStatus.pausePosition / getDuration();
+ } else {
+ return 1;
+ }
+ }
+ public function onMetaDataHandler(info:Object):void { // Used in connectStream() in myStream.client object.
+ // This event occurs when jumping to the start of static files! ie., seek(0) will cause this event to occur.
+ if(!myStatus.metaDataReady) {
+ this.dispatchEvent(new JplayerEvent(JplayerEvent.DEBUG_MSG, myStatus, "onMetaDataHandler: " + info.duration + " | " + info.width + "x" + info.height));
+
+ myStatus.metaDataReady = true; // Set flag so that this event only effects jPlayer the 1st time.
+ myStatus.metaData = info;
+ myStatus.duration = info.duration * 1000; // Only available via Meta Data.
+ if(info.width != undefined) {
+ myVideo.width = info.width;
+ }
+ if(info.height != undefined) {
+ myVideo.height = info.height;
+ }
+
+ if(myStatus.playOnLoad) {
+ myStatus.playOnLoad = false; // Capture the flag
+ if(myStatus.pausePosition > 0 ) { // Important for setMedia followed by play(time).
+ play(myStatus.pausePosition);
+ } else {
+ play(); // Not always sending pausePosition avoids the extra seek(0) for a normal play() command.
+ }
+ } else {
+ pause(myStatus.pausePosition); // Always send the pausePosition. Important for setMedia() followed by pause(time). Deals with not reading stream.time with setMedia() and play() immediately followed by stop() or pause(0)
+ }
+ this.dispatchEvent(new JplayerEvent(JplayerEvent.JPLAYER_LOADEDMETADATA, myStatus));
+ } else {
+ this.dispatchEvent(new JplayerEvent(JplayerEvent.DEBUG_MSG, myStatus, "onMetaDataHandler: Already read (NO EFFECT)"));
+ }
+ }
+ }
+}
diff --git a/apps/media/js/jQuery.jPlayer.2.1.0.source/happyworm/jPlayer/JplayerStatus.as b/apps/media/js/jQuery.jPlayer.2.1.0.source/happyworm/jPlayer/JplayerStatus.as
new file mode 100644
index 00000000000..5cc1e1ff4b3
--- /dev/null
+++ b/apps/media/js/jQuery.jPlayer.2.1.0.source/happyworm/jPlayer/JplayerStatus.as
@@ -0,0 +1,101 @@
+/*
+ * jPlayer Plugin for jQuery JavaScript Library
+ * http://www.happyworm.com/jquery/jplayer
+ *
+ * Copyright (c) 2009 - 2011 Happyworm Ltd
+ * Dual licensed under the MIT and GPL licenses.
+ * - http://www.opensource.org/licenses/mit-license.php
+ * - http://www.gnu.org/copyleft/gpl.html
+ *
+ * Author: Mark J Panaghiston
+ * Date: 1st September 2011
+ */
+
+package happyworm.jPlayer {
+ public class JplayerStatus {
+
+ public static const VERSION:String = "2.1.0"; // The version of the Flash jPlayer entity.
+
+ public var volume:Number = 0.5; // Not affected by reset()
+ public var muted:Boolean = false; // Not affected by reset()
+
+ public var src:String;
+ public var srcError:Boolean;
+
+ public var srcSet:Boolean;
+ public var isPlaying:Boolean;
+ public var isSeeking:Boolean;
+
+ public var playOnLoad:Boolean;
+ public var playOnSeek:Boolean;
+
+ public var isStartingDownload:Boolean;
+ public var isLoading:Boolean;
+ public var isLoaded:Boolean;
+
+ public var pausePosition:Number;
+
+ public var seekPercent:Number;
+ public var currentTime:Number;
+ public var currentPercentRelative:Number;
+ public var currentPercentAbsolute:Number;
+ public var duration:Number;
+
+ public var metaDataReady:Boolean;
+ public var metaData:Object;
+
+ public function JplayerStatus() {
+ reset();
+ }
+ public function reset():void {
+ src = "";
+ srcError = false;
+
+ srcSet = false;
+ isPlaying = false;
+ isSeeking = false;
+
+ playOnLoad = false;
+ playOnSeek = false;
+
+ isStartingDownload = false;
+ isLoading = false;
+ isLoaded = false;
+
+ pausePosition = 0;
+
+ seekPercent = 0;
+ currentTime = 0;
+ currentPercentRelative = 0;
+ currentPercentAbsolute = 0;
+ duration = 0;
+
+ metaDataReady = false;
+ metaData = {};
+ }
+ public function error():void {
+ var srcSaved:String = src;
+ reset();
+ src = srcSaved;
+ srcError = true;
+ }
+ public function loadRequired():Boolean {
+ return (srcSet && !isStartingDownload && !isLoading && !isLoaded);
+ }
+ public function startingDownload():void {
+ isStartingDownload = true;
+ isLoading = false;
+ isLoaded = false;
+ }
+ public function loading():void {
+ isStartingDownload = false;
+ isLoading = true;
+ isLoaded = false;
+ }
+ public function loaded():void {
+ isStartingDownload = false;
+ isLoading = false;
+ isLoaded = true;
+ }
+ }
+}
diff --git a/apps/media/js/jQuery.jPlayer.2.1.0.source/jquery.jplayer.js b/apps/media/js/jQuery.jPlayer.2.1.0.source/jquery.jplayer.js
new file mode 100644
index 00000000000..9d41a12ee6c
--- /dev/null
+++ b/apps/media/js/jQuery.jPlayer.2.1.0.source/jquery.jplayer.js
@@ -0,0 +1,2349 @@
+/*
+ * jPlayer Plugin for jQuery JavaScript Library
+ * http://www.jplayer.org
+ *
+ * Copyright (c) 2009 - 2011 Happyworm Ltd
+ * Dual licensed under the MIT and GPL licenses.
+ * - http://www.opensource.org/licenses/mit-license.php
+ * - http://www.gnu.org/copyleft/gpl.html
+ *
+ * Author: Mark J Panaghiston
+ * Version: 2.1.0
+ * Date: 1st September 2011
+ */
+
+/* Code verified using http://www.jshint.com/ */
+/*jshint asi:false, bitwise:false, boss:false, browser:true, curly:true, debug:false, eqeqeq:true, eqnull:false, evil:false, forin:false, immed:false, jquery:true, laxbreak:false, newcap:true, noarg:true, noempty:true, nonew:true, nomem:false, onevar:false, passfail:false, plusplus:false, regexp:false, undef:true, sub:false, strict:false, white:false */
+/*global jQuery:false, ActiveXObject:false, alert:false */
+
+(function($, undefined) {
+
+ // Adapted from jquery.ui.widget.js (1.8.7): $.widget.bridge
+ $.fn.jPlayer = function( options ) {
+ var name = "jPlayer";
+ var isMethodCall = typeof options === "string",
+ args = Array.prototype.slice.call( arguments, 1 ),
+ returnValue = this;
+
+ // allow multiple hashes to be passed on init
+ options = !isMethodCall && args.length ?
+ $.extend.apply( null, [ true, options ].concat(args) ) :
+ options;
+
+ // prevent calls to internal methods
+ if ( isMethodCall && options.charAt( 0 ) === "_" ) {
+ return returnValue;
+ }
+
+ if ( isMethodCall ) {
+ this.each(function() {
+ var instance = $.data( this, name ),
+ methodValue = instance && $.isFunction( instance[options] ) ?
+ instance[ options ].apply( instance, args ) :
+ instance;
+ if ( methodValue !== instance && methodValue !== undefined ) {
+ returnValue = methodValue;
+ return false;
+ }
+ });
+ } else {
+ this.each(function() {
+ var instance = $.data( this, name );
+ if ( instance ) {
+ // instance.option( options || {} )._init(); // Orig jquery.ui.widget.js code: Not recommend for jPlayer. ie., Applying new options to an existing instance (via the jPlayer constructor) and performing the _init(). The _init() is what concerns me. It would leave a lot of event handlers acting on jPlayer instance and the interface.
+ instance.option( options || {} ); // The new constructor only changes the options. Changing options only has basic support atm.
+ } else {
+ $.data( this, name, new $.jPlayer( options, this ) );
+ }
+ });
+ }
+
+ return returnValue;
+ };
+
+ $.jPlayer = function( options, element ) {
+ // allow instantiation without initializing for simple inheritance
+ if ( arguments.length ) {
+ this.element = $(element);
+ this.options = $.extend(true, {},
+ this.options,
+ options
+ );
+ var self = this;
+ this.element.bind( "remove.jPlayer", function() {
+ self.destroy();
+ });
+ this._init();
+ }
+ };
+ // End of: (Adapted from jquery.ui.widget.js (1.8.7))
+
+ // Emulated HTML5 methods and properties
+ $.jPlayer.emulateMethods = "load play pause";
+ $.jPlayer.emulateStatus = "src readyState networkState currentTime duration paused ended playbackRate";
+ $.jPlayer.emulateOptions = "muted volume";
+
+ // Reserved event names generated by jPlayer that are not part of the HTML5 Media element spec
+ $.jPlayer.reservedEvent = "ready flashreset resize repeat error warning";
+
+ // Events generated by jPlayer
+ $.jPlayer.event = {
+ ready: "jPlayer_ready",
+ flashreset: "jPlayer_flashreset", // Similar to the ready event if the Flash solution is set to display:none and then shown again or if it's reloaded for another reason by the browser. For example, using CSS position:fixed on Firefox for the full screen feature.
+ resize: "jPlayer_resize", // Occurs when the size changes through a full/restore screen operation or if the size/sizeFull options are changed.
+ repeat: "jPlayer_repeat", // Occurs when the repeat status changes. Usually through clicks on the repeat button of the interface.
+ click: "jPlayer_click", // Occurs when the user clicks on one of the following: poster image, html video, flash video.
+ error: "jPlayer_error", // Event error code in event.jPlayer.error.type. See $.jPlayer.error
+ warning: "jPlayer_warning", // Event warning code in event.jPlayer.warning.type. See $.jPlayer.warning
+
+ // Other events match HTML5 spec.
+ loadstart: "jPlayer_loadstart",
+ progress: "jPlayer_progress",
+ suspend: "jPlayer_suspend",
+ abort: "jPlayer_abort",
+ emptied: "jPlayer_emptied",
+ stalled: "jPlayer_stalled",
+ play: "jPlayer_play",
+ pause: "jPlayer_pause",
+ loadedmetadata: "jPlayer_loadedmetadata",
+ loadeddata: "jPlayer_loadeddata",
+ waiting: "jPlayer_waiting",
+ playing: "jPlayer_playing",
+ canplay: "jPlayer_canplay",
+ canplaythrough: "jPlayer_canplaythrough",
+ seeking: "jPlayer_seeking",
+ seeked: "jPlayer_seeked",
+ timeupdate: "jPlayer_timeupdate",
+ ended: "jPlayer_ended",
+ ratechange: "jPlayer_ratechange",
+ durationchange: "jPlayer_durationchange",
+ volumechange: "jPlayer_volumechange"
+ };
+
+ $.jPlayer.htmlEvent = [ // These HTML events are bubbled through to the jPlayer event, without any internal action.
+ "loadstart",
+ // "progress", // jPlayer uses internally before bubbling.
+ // "suspend", // jPlayer uses internally before bubbling.
+ "abort",
+ // "error", // jPlayer uses internally before bubbling.
+ "emptied",
+ "stalled",
+ // "play", // jPlayer uses internally before bubbling.
+ // "pause", // jPlayer uses internally before bubbling.
+ "loadedmetadata",
+ "loadeddata",
+ // "waiting", // jPlayer uses internally before bubbling.
+ // "playing", // jPlayer uses internally before bubbling.
+ "canplay",
+ "canplaythrough",
+ // "seeking", // jPlayer uses internally before bubbling.
+ // "seeked", // jPlayer uses internally before bubbling.
+ // "timeupdate", // jPlayer uses internally before bubbling.
+ // "ended", // jPlayer uses internally before bubbling.
+ "ratechange"
+ // "durationchange" // jPlayer uses internally before bubbling.
+ // "volumechange" // jPlayer uses internally before bubbling.
+ ];
+
+ $.jPlayer.pause = function() {
+ $.each($.jPlayer.prototype.instances, function(i, element) {
+ if(element.data("jPlayer").status.srcSet) { // Check that media is set otherwise would cause error event.
+ element.jPlayer("pause");
+ }
+ });
+ };
+
+ $.jPlayer.timeFormat = {
+ showHour: false,
+ showMin: true,
+ showSec: true,
+ padHour: false,
+ padMin: true,
+ padSec: true,
+ sepHour: ":",
+ sepMin: ":",
+ sepSec: ""
+ };
+
+ $.jPlayer.convertTime = function(s) {
+ var myTime = new Date(s * 1000);
+ var hour = myTime.getUTCHours();
+ var min = myTime.getUTCMinutes();
+ var sec = myTime.getUTCSeconds();
+ var strHour = ($.jPlayer.timeFormat.padHour && hour < 10) ? "0" + hour : hour;
+ var strMin = ($.jPlayer.timeFormat.padMin && min < 10) ? "0" + min : min;
+ var strSec = ($.jPlayer.timeFormat.padSec && sec < 10) ? "0" + sec : sec;
+ return (($.jPlayer.timeFormat.showHour) ? strHour + $.jPlayer.timeFormat.sepHour : "") + (($.jPlayer.timeFormat.showMin) ? strMin + $.jPlayer.timeFormat.sepMin : "") + (($.jPlayer.timeFormat.showSec) ? strSec + $.jPlayer.timeFormat.sepSec : "");
+ };
+
+ // Adapting jQuery 1.4.4 code for jQuery.browser. Required since jQuery 1.3.2 does not detect Chrome as webkit.
+ $.jPlayer.uaBrowser = function( userAgent ) {
+ var ua = userAgent.toLowerCase();
+
+ // Useragent RegExp
+ var rwebkit = /(webkit)[ \/]([\w.]+)/;
+ var ropera = /(opera)(?:.*version)?[ \/]([\w.]+)/;
+ var rmsie = /(msie) ([\w.]+)/;
+ var rmozilla = /(mozilla)(?:.*? rv:([\w.]+))?/;
+
+ 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" };
+ };
+
+ // Platform sniffer for detecting mobile devices
+ $.jPlayer.uaPlatform = function( userAgent ) {
+ var ua = userAgent.toLowerCase();
+
+ // Useragent RegExp
+ var rplatform = /(ipad|iphone|ipod|android|blackberry|playbook|windows ce|webos)/;
+ var rtablet = /(ipad|playbook)/;
+ var randroid = /(android)/;
+ var rmobile = /(mobile)/;
+
+ var platform = rplatform.exec( ua ) || [];
+ var tablet = rtablet.exec( ua ) ||
+ !rmobile.exec( ua ) && randroid.exec( ua ) ||
+ [];
+
+ if(platform[1]) {
+ platform[1] = platform[1].replace(/\s/g, "_"); // Change whitespace to underscore. Enables dot notation.
+ }
+
+ return { platform: platform[1] || "", tablet: tablet[1] || "" };
+ };
+
+ $.jPlayer.browser = {
+ };
+ $.jPlayer.platform = {
+ };
+
+ var browserMatch = $.jPlayer.uaBrowser(navigator.userAgent);
+ if ( browserMatch.browser ) {
+ $.jPlayer.browser[ browserMatch.browser ] = true;
+ $.jPlayer.browser.version = browserMatch.version;
+ }
+ var platformMatch = $.jPlayer.uaPlatform(navigator.userAgent);
+ if ( platformMatch.platform ) {
+ $.jPlayer.platform[ platformMatch.platform ] = true;
+ $.jPlayer.platform.mobile = !platformMatch.tablet;
+ $.jPlayer.platform.tablet = !!platformMatch.tablet;
+ }
+
+ $.jPlayer.prototype = {
+ count: 0, // Static Variable: Change it via prototype.
+ version: { // Static Object
+ script: "2.1.0",
+ needFlash: "2.1.0",
+ flash: "unknown"
+ },
+ options: { // Instanced in $.jPlayer() constructor
+ swfPath: "js", // Path to Jplayer.swf. Can be relative, absolute or server root relative.
+ solution: "html, flash", // Valid solutions: html, flash. Order defines priority. 1st is highest,
+ supplied: "mp3", // Defines which formats jPlayer will try and support and the priority by the order. 1st is highest,
+ preload: 'metadata', // HTML5 Spec values: none, metadata, auto.
+ volume: 0.8, // The volume. Number 0 to 1.
+ muted: false,
+ wmode: "opaque", // Valid wmode: window, transparent, opaque, direct, gpu.
+ backgroundColor: "#000000", // To define the jPlayer div and Flash background color.
+ cssSelectorAncestor: "#jp_container_1",
+ cssSelector: { // * denotes properties that should only be required when video media type required. _cssSelector() would require changes to enable splitting these into Audio and Video defaults.
+ videoPlay: ".jp-video-play", // *
+ play: ".jp-play",
+ pause: ".jp-pause",
+ stop: ".jp-stop",
+ seekBar: ".jp-seek-bar",
+ playBar: ".jp-play-bar",
+ mute: ".jp-mute",
+ unmute: ".jp-unmute",
+ volumeBar: ".jp-volume-bar",
+ volumeBarValue: ".jp-volume-bar-value",
+ volumeMax: ".jp-volume-max",
+ currentTime: ".jp-current-time",
+ duration: ".jp-duration",
+ fullScreen: ".jp-full-screen", // *
+ restoreScreen: ".jp-restore-screen", // *
+ repeat: ".jp-repeat",
+ repeatOff: ".jp-repeat-off",
+ gui: ".jp-gui", // The interface used with autohide feature.
+ noSolution: ".jp-no-solution" // For error feedback when jPlayer cannot find a solution.
+ },
+ fullScreen: false,
+ autohide: {
+ restored: false, // Controls the interface autohide feature.
+ full: true, // Controls the interface autohide feature.
+ fadeIn: 200, // Milliseconds. The period of the fadeIn anim.
+ fadeOut: 600, // Milliseconds. The period of the fadeOut anim.
+ hold: 1000 // Milliseconds. The period of the pause before autohide beings.
+ },
+ loop: false,
+ repeat: function(event) { // The default jPlayer repeat event handler
+ if(event.jPlayer.options.loop) {
+ $(this).unbind(".jPlayerRepeat").bind($.jPlayer.event.ended + ".jPlayer.jPlayerRepeat", function() {
+ $(this).jPlayer("play");
+ });
+ } else {
+ $(this).unbind(".jPlayerRepeat");
+ }
+ },
+ nativeVideoControls: {
+ // Works well on standard browsers.
+ // Phone and tablet browsers can have problems with the controls disappearing.
+ },
+ noFullScreen: {
+ msie: /msie [0-6]/,
+ ipad: /ipad.*?os [0-4]/,
+ iphone: /iphone/,
+ ipod: /ipod/,
+ android_pad: /android [0-3](?!.*?mobile)/,
+ android_phone: /android.*?mobile/,
+ blackberry: /blackberry/,
+ windows_ce: /windows ce/,
+ webos: /webos/
+ },
+ noVolume: {
+ ipad: /ipad/,
+ iphone: /iphone/,
+ ipod: /ipod/,
+ android_pad: /android(?!.*?mobile)/,
+ android_phone: /android.*?mobile/,
+ blackberry: /blackberry/,
+ windows_ce: /windows ce/,
+ webos: /webos/,
+ playbook: /playbook/
+ },
+ verticalVolume: false, // Calculate volume from the bottom of the volume bar. Default is from the left. Also volume affects either width or height.
+ // globalVolume: false, // Not implemented: Set to make volume changes affect all jPlayer instances
+ // globalMute: false, // Not implemented: Set to make mute changes affect all jPlayer instances
+ idPrefix: "jp", // Prefix for the ids of html elements created by jPlayer. For flash, this must not include characters: . - + * / \
+ noConflict: "jQuery",
+ emulateHtml: false, // Emulates the HTML5 Media element on the jPlayer element.
+ errorAlerts: false,
+ warningAlerts: false
+ },
+ optionsAudio: {
+ size: {
+ width: "0px",
+ height: "0px",
+ cssClass: ""
+ },
+ sizeFull: {
+ width: "0px",
+ height: "0px",
+ cssClass: ""
+ }
+ },
+ optionsVideo: {
+ size: {
+ width: "480px",
+ height: "270px",
+ cssClass: "jp-video-270p"
+ },
+ sizeFull: {
+ width: "100%",
+ height: "100%",
+ cssClass: "jp-video-full"
+ }
+ },
+ instances: {}, // Static Object
+ status: { // Instanced in _init()
+ src: "",
+ media: {},
+ paused: true,
+ format: {},
+ formatType: "",
+ waitForPlay: true, // Same as waitForLoad except in case where preloading.
+ waitForLoad: true,
+ srcSet: false,
+ video: false, // True if playing a video
+ seekPercent: 0,
+ currentPercentRelative: 0,
+ currentPercentAbsolute: 0,
+ currentTime: 0,
+ duration: 0,
+ readyState: 0,
+ networkState: 0,
+ playbackRate: 1,
+ ended: 0
+
+/* Persistant status properties created dynamically at _init():
+ width
+ height
+ cssClass
+ nativeVideoControls
+ noFullScreen
+ noVolume
+*/
+ },
+
+ internal: { // Instanced in _init()
+ ready: false
+ // instance: undefined
+ // domNode: undefined
+ // htmlDlyCmdId: undefined
+ // autohideId: undefined
+ },
+ solution: { // Static Object: Defines the solutions built in jPlayer.
+ html: true,
+ flash: true
+ },
+ // 'MPEG-4 support' : canPlayType('video/mp4; codecs="mp4v.20.8"')
+ format: { // Static Object
+ mp3: {
+ codec: 'audio/mpeg; codecs="mp3"',
+ flashCanPlay: true,
+ media: 'audio'
+ },
+ m4a: { // AAC / MP4
+ codec: 'audio/mp4; codecs="mp4a.40.2"',
+ flashCanPlay: true,
+ media: 'audio'
+ },
+ oga: { // OGG
+ codec: 'audio/ogg; codecs="vorbis"',
+ flashCanPlay: false,
+ media: 'audio'
+ },
+ wav: { // PCM
+ codec: 'audio/wav; codecs="1"',
+ flashCanPlay: false,
+ media: 'audio'
+ },
+ webma: { // WEBM
+ codec: 'audio/webm; codecs="vorbis"',
+ flashCanPlay: false,
+ media: 'audio'
+ },
+ fla: { // FLV / F4A
+ codec: 'audio/x-flv',
+ flashCanPlay: true,
+ media: 'audio'
+ },
+ m4v: { // H.264 / MP4
+ codec: 'video/mp4; codecs="avc1.42E01E, mp4a.40.2"',
+ flashCanPlay: true,
+ media: 'video'
+ },
+ ogv: { // OGG
+ codec: 'video/ogg; codecs="theora, vorbis"',
+ flashCanPlay: false,
+ media: 'video'
+ },
+ webmv: { // WEBM
+ codec: 'video/webm; codecs="vorbis, vp8"',
+ flashCanPlay: false,
+ media: 'video'
+ },
+ flv: { // FLV / F4V
+ codec: 'video/x-flv',
+ flashCanPlay: true,
+ media: 'video'
+ }
+ },
+ _init: function() {
+ var self = this;
+
+ this.element.empty();
+
+ this.status = $.extend({}, this.status); // Copy static to unique instance.
+ this.internal = $.extend({}, this.internal); // Copy static to unique instance.
+
+ this.internal.domNode = this.element.get(0);
+
+ this.formats = []; // Array based on supplied string option. Order defines priority.
+ this.solutions = []; // Array based on solution string option. Order defines priority.
+ this.require = {}; // Which media types are required: video, audio.
+
+ this.htmlElement = {}; // DOM elements created by jPlayer
+ this.html = {}; // In _init()'s this.desired code and setmedia(): Accessed via this[solution], where solution from this.solutions array.
+ this.html.audio = {};
+ this.html.video = {};
+ this.flash = {}; // In _init()'s this.desired code and setmedia(): Accessed via this[solution], where solution from this.solutions array.
+
+ this.css = {};
+ this.css.cs = {}; // Holds the css selector strings
+ this.css.jq = {}; // Holds jQuery selectors. ie., $(css.cs.method)
+
+ this.ancestorJq = []; // Holds jQuery selector of cssSelectorAncestor. Init would use $() instead of [], but it is only 1.4+
+
+ this.options.volume = this._limitValue(this.options.volume, 0, 1); // Limit volume value's bounds.
+
+ // Create the formats array, with prority based on the order of the supplied formats string
+ $.each(this.options.supplied.toLowerCase().split(","), function(index1, value1) {
+ var format = value1.replace(/^\s+|\s+$/g, ""); //trim
+ if(self.format[format]) { // Check format is valid.
+ var dupFound = false;
+ $.each(self.formats, function(index2, value2) { // Check for duplicates
+ if(format === value2) {
+ dupFound = true;
+ return false;
+ }
+ });
+ if(!dupFound) {
+ self.formats.push(format);
+ }
+ }
+ });
+
+ // Create the solutions array, with prority based on the order of the solution string
+ $.each(this.options.solution.toLowerCase().split(","), function(index1, value1) {
+ var solution = value1.replace(/^\s+|\s+$/g, ""); //trim
+ if(self.solution[solution]) { // Check solution is valid.
+ var dupFound = false;
+ $.each(self.solutions, function(index2, value2) { // Check for duplicates
+ if(solution === value2) {
+ dupFound = true;
+ return false;
+ }
+ });
+ if(!dupFound) {
+ self.solutions.push(solution);
+ }
+ }
+ });
+
+ this.internal.instance = "jp_" + this.count;
+ this.instances[this.internal.instance] = this.element;
+
+ // Check the jPlayer div has an id and create one if required. Important for Flash to know the unique id for comms.
+ if(!this.element.attr("id")) {
+ this.element.attr("id", this.options.idPrefix + "_jplayer_" + this.count);
+ }
+
+ this.internal.self = $.extend({}, {
+ id: this.element.attr("id"),
+ jq: this.element
+ });
+ this.internal.audio = $.extend({}, {
+ id: this.options.idPrefix + "_audio_" + this.count,
+ jq: undefined
+ });
+ this.internal.video = $.extend({}, {
+ id: this.options.idPrefix + "_video_" + this.count,
+ jq: undefined
+ });
+ this.internal.flash = $.extend({}, {
+ id: this.options.idPrefix + "_flash_" + this.count,
+ jq: undefined,
+ swf: this.options.swfPath + (this.options.swfPath.toLowerCase().slice(-4) !== ".swf" ? (this.options.swfPath && this.options.swfPath.slice(-1) !== "/" ? "/" : "") + "Jplayer.swf" : "")
+ });
+ this.internal.poster = $.extend({}, {
+ id: this.options.idPrefix + "_poster_" + this.count,
+ jq: undefined
+ });
+
+ // Register listeners defined in the constructor
+ $.each($.jPlayer.event, function(eventName,eventType) {
+ if(self.options[eventName] !== undefined) {
+ self.element.bind(eventType + ".jPlayer", self.options[eventName]); // With .jPlayer namespace.
+ self.options[eventName] = undefined; // Destroy the handler pointer copy on the options. Reason, events can be added/removed in other ways so this could be obsolete and misleading.
+ }
+ });
+
+ // Determine if we require solutions for audio, video or both media types.
+ this.require.audio = false;
+ this.require.video = false;
+ $.each(this.formats, function(priority, format) {
+ self.require[self.format[format].media] = true;
+ });
+
+ // Now required types are known, finish the options default settings.
+ if(this.require.video) {
+ this.options = $.extend(true, {},
+ this.optionsVideo,
+ this.options
+ );
+ } else {
+ this.options = $.extend(true, {},
+ this.optionsAudio,
+ this.options
+ );
+ }
+ this._setSize(); // update status and jPlayer element size
+
+ // Determine the status for Blocklisted options.
+ this.status.nativeVideoControls = this._uaBlocklist(this.options.nativeVideoControls);
+ this.status.noFullScreen = this._uaBlocklist(this.options.noFullScreen);
+ this.status.noVolume = this._uaBlocklist(this.options.noVolume);
+
+ // The native controls are only for video and are disabled when audio is also used.
+ this._restrictNativeVideoControls();
+
+ // Create the poster image.
+ this.htmlElement.poster = document.createElement('img');
+ this.htmlElement.poster.id = this.internal.poster.id;
+ this.htmlElement.poster.onload = function() { // Note that this did not work on Firefox 3.6: poster.addEventListener("onload", function() {}, false); Did not investigate x-browser.
+ if(!self.status.video || self.status.waitForPlay) {
+ self.internal.poster.jq.show();
+ }
+ };
+ this.element.append(this.htmlElement.poster);
+ this.internal.poster.jq = $("#" + this.internal.poster.id);
+ this.internal.poster.jq.css({'width': this.status.width, 'height': this.status.height});
+ this.internal.poster.jq.hide();
+ this.internal.poster.jq.bind("click.jPlayer", function() {
+ self._trigger($.jPlayer.event.click);
+ });
+
+ // Generate the required media elements
+ this.html.audio.available = false;
+ if(this.require.audio) { // If a supplied format is audio
+ this.htmlElement.audio = document.createElement('audio');
+ this.htmlElement.audio.id = this.internal.audio.id;
+ this.html.audio.available = !!this.htmlElement.audio.canPlayType && this._testCanPlayType(this.htmlElement.audio); // Test is for IE9 on Win Server 2008.
+ }
+ this.html.video.available = false;
+ if(this.require.video) { // If a supplied format is video
+ this.htmlElement.video = document.createElement('video');
+ this.htmlElement.video.id = this.internal.video.id;
+ this.html.video.available = !!this.htmlElement.video.canPlayType && this._testCanPlayType(this.htmlElement.video); // Test is for IE9 on Win Server 2008.
+ }
+
+ this.flash.available = this._checkForFlash(10);
+
+ this.html.canPlay = {};
+ this.flash.canPlay = {};
+ $.each(this.formats, function(priority, format) {
+ self.html.canPlay[format] = self.html[self.format[format].media].available && "" !== self.htmlElement[self.format[format].media].canPlayType(self.format[format].codec);
+ self.flash.canPlay[format] = self.format[format].flashCanPlay && self.flash.available;
+ });
+ this.html.desired = false;
+ this.flash.desired = false;
+ $.each(this.solutions, function(solutionPriority, solution) {
+ if(solutionPriority === 0) {
+ self[solution].desired = true;
+ } else {
+ var audioCanPlay = false;
+ var videoCanPlay = false;
+ $.each(self.formats, function(formatPriority, format) {
+ if(self[self.solutions[0]].canPlay[format]) { // The other solution can play
+ if(self.format[format].media === 'video') {
+ videoCanPlay = true;
+ } else {
+ audioCanPlay = true;
+ }
+ }
+ });
+ self[solution].desired = (self.require.audio && !audioCanPlay) || (self.require.video && !videoCanPlay);
+ }
+ });
+ // This is what jPlayer will support, based on solution and supplied.
+ this.html.support = {};
+ this.flash.support = {};
+ $.each(this.formats, function(priority, format) {
+ self.html.support[format] = self.html.canPlay[format] && self.html.desired;
+ self.flash.support[format] = self.flash.canPlay[format] && self.flash.desired;
+ });
+ // If jPlayer is supporting any format in a solution, then the solution is used.
+ this.html.used = false;
+ this.flash.used = false;
+ $.each(this.solutions, function(solutionPriority, solution) {
+ $.each(self.formats, function(formatPriority, format) {
+ if(self[solution].support[format]) {
+ self[solution].used = true;
+ return false;
+ }
+ });
+ });
+
+ // Init solution active state and the event gates to false.
+ this._resetActive();
+ this._resetGate();
+
+ // Set up the css selectors for the control and feedback entities.
+ this._cssSelectorAncestor(this.options.cssSelectorAncestor);
+
+ // If neither html nor flash are being used by this browser, then media playback is not possible. Trigger an error event.
+ if(!(this.html.used || this.flash.used)) {
+ this._error( {
+ type: $.jPlayer.error.NO_SOLUTION,
+ context: "{solution:'" + this.options.solution + "', supplied:'" + this.options.supplied + "'}",
+ message: $.jPlayer.errorMsg.NO_SOLUTION,
+ hint: $.jPlayer.errorHint.NO_SOLUTION
+ });
+ if(this.css.jq.noSolution.length) {
+ this.css.jq.noSolution.show();
+ }
+ } else {
+ if(this.css.jq.noSolution.length) {
+ this.css.jq.noSolution.hide();
+ }
+ }
+
+ // Add the flash solution if it is being used.
+ if(this.flash.used) {
+ var htmlObj,
+ flashVars = 'jQuery=' + encodeURI(this.options.noConflict) + '&id=' + encodeURI(this.internal.self.id) + '&vol=' + this.options.volume + '&muted=' + this.options.muted;
+
+ // Code influenced by SWFObject 2.2: http://code.google.com/p/swfobject/
+ // Non IE browsers have an initial Flash size of 1 by 1 otherwise the wmode affected the Flash ready event.
+
+ if($.browser.msie && Number($.browser.version) <= 8) {
+ var objStr = '<object id="' + this.internal.flash.id + '" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="0" height="0"></object>';
+
+ var paramStr = [
+ '<param name="movie" value="' + this.internal.flash.swf + '" />',
+ '<param name="FlashVars" value="' + flashVars + '" />',
+ '<param name="allowScriptAccess" value="always" />',
+ '<param name="bgcolor" value="' + this.options.backgroundColor + '" />',
+ '<param name="wmode" value="' + this.options.wmode + '" />'
+ ];
+
+ htmlObj = document.createElement(objStr);
+ for(var i=0; i < paramStr.length; i++) {
+ htmlObj.appendChild(document.createElement(paramStr[i]));
+ }
+ } else {
+ var createParam = function(el, n, v) {
+ var p = document.createElement("param");
+ p.setAttribute("name", n);
+ p.setAttribute("value", v);
+ el.appendChild(p);
+ };
+
+ htmlObj = document.createElement("object");
+ htmlObj.setAttribute("id", this.internal.flash.id);
+ htmlObj.setAttribute("data", this.internal.flash.swf);
+ htmlObj.setAttribute("type", "application/x-shockwave-flash");
+ htmlObj.setAttribute("width", "1"); // Non-zero
+ htmlObj.setAttribute("height", "1"); // Non-zero
+ createParam(htmlObj, "flashvars", flashVars);
+ createParam(htmlObj, "allowscriptaccess", "always");
+ createParam(htmlObj, "bgcolor", this.options.backgroundColor);
+ createParam(htmlObj, "wmode", this.options.wmode);
+ }
+
+ this.element.append(htmlObj);
+ this.internal.flash.jq = $(htmlObj);
+ }
+
+ // Add the HTML solution if being used.
+ if(this.html.used) {
+
+ // The HTML Audio handlers
+ if(this.html.audio.available) {
+ this._addHtmlEventListeners(this.htmlElement.audio, this.html.audio);
+ this.element.append(this.htmlElement.audio);
+ this.internal.audio.jq = $("#" + this.internal.audio.id);
+ }
+
+ // The HTML Video handlers
+ if(this.html.video.available) {
+ this._addHtmlEventListeners(this.htmlElement.video, this.html.video);
+ this.element.append(this.htmlElement.video);
+ this.internal.video.jq = $("#" + this.internal.video.id);
+ if(this.status.nativeVideoControls) {
+ this.internal.video.jq.css({'width': this.status.width, 'height': this.status.height});
+ } else {
+ this.internal.video.jq.css({'width':'0px', 'height':'0px'}); // Using size 0x0 since a .hide() causes issues in iOS
+ }
+ this.internal.video.jq.bind("click.jPlayer", function() {
+ self._trigger($.jPlayer.event.click);
+ });
+ }
+ }
+
+ // Create the bridge that emulates the HTML Media element on the jPlayer DIV
+ if( this.options.emulateHtml ) {
+ this._emulateHtmlBridge();
+ }
+
+ if(this.html.used && !this.flash.used) { // If only HTML, then emulate flash ready() call after 100ms.
+ setTimeout( function() {
+ self.internal.ready = true;
+ self.version.flash = "n/a";
+ self._trigger($.jPlayer.event.repeat); // Trigger the repeat event so its handler can initialize itself with the loop option.
+ self._trigger($.jPlayer.event.ready);
+ }, 100);
+ }
+
+ // Initialize the interface components with the options.
+ this._updateNativeVideoControls(); // Must do this first, otherwise there is a bizarre bug in iOS 4.3.2, where the native controls are not shown. Fails in iOS if called after _updateButtons() below. Works if called later in setMedia too, so it odd.
+ this._updateInterface();
+ this._updateButtons(false);
+ this._updateAutohide();
+ this._updateVolume(this.options.volume);
+ this._updateMute(this.options.muted);
+ if(this.css.jq.videoPlay.length) {
+ this.css.jq.videoPlay.hide();
+ }
+
+ $.jPlayer.prototype.count++; // Change static variable via prototype.
+ },
+ destroy: function() {
+ // MJP: The background change remains. Would need to store the original to restore it correctly.
+ // MJP: The jPlayer element's size change remains.
+
+ // Clear the media to reset the GUI and stop any downloads. Streams on some browsers had persited. (Chrome)
+ this.clearMedia();
+ // Remove the size/sizeFull cssClass from the cssSelectorAncestor
+ this._removeUiClass();
+ // Remove the times from the GUI
+ if(this.css.jq.currentTime.length) {
+ this.css.jq.currentTime.text("");
+ }
+ if(this.css.jq.duration.length) {
+ this.css.jq.duration.text("");
+ }
+ // Remove any bindings from the interface controls.
+ $.each(this.css.jq, function(fn, jq) {
+ // Check selector is valid before trying to execute method.
+ if(jq.length) {
+ jq.unbind(".jPlayer");
+ }
+ });
+ // Remove the click handlers for $.jPlayer.event.click
+ this.internal.poster.jq.unbind(".jPlayer");
+ if(this.internal.video.jq) {
+ this.internal.video.jq.unbind(".jPlayer");
+ }
+ // Destroy the HTML bridge.
+ if(this.options.emulateHtml) {
+ this._destroyHtmlBridge();
+ }
+ this.element.removeData("jPlayer"); // Remove jPlayer data
+ this.element.unbind(".jPlayer"); // Remove all event handlers created by the jPlayer constructor
+ this.element.empty(); // Remove the inserted child elements
+
+ delete this.instances[this.internal.instance]; // Clear the instance on the static instance object
+ },
+ enable: function() { // Plan to implement
+ // options.disabled = false
+ },
+ disable: function () { // Plan to implement
+ // options.disabled = true
+ },
+ _testCanPlayType: function(elem) {
+ // IE9 on Win Server 2008 did not implement canPlayType(), but it has the property.
+ try {
+ elem.canPlayType(this.format.mp3.codec); // The type is irrelevant.
+ return true;
+ } catch(err) {
+ return false;
+ }
+ },
+ _uaBlocklist: function(list) {
+ // list : object with properties that are all regular expressions. Property names are irrelevant.
+ // Returns true if the user agent is matched in list.
+ var ua = navigator.userAgent.toLowerCase(),
+ block = false;
+
+ $.each(list, function(p, re) {
+ if(re && re.test(ua)) {
+ block = true;
+ return false; // exit $.each.
+ }
+ });
+ return block;
+ },
+ _restrictNativeVideoControls: function() {
+ // Fallback to noFullScreen when nativeVideoControls is true and audio media is being used. Affects when both media types are used.
+ if(this.require.audio) {
+ if(this.status.nativeVideoControls) {
+ this.status.nativeVideoControls = false;
+ this.status.noFullScreen = true;
+ }
+ }
+ },
+ _updateNativeVideoControls: function() {
+ if(this.html.video.available && this.html.used) {
+ // Turn the HTML Video controls on/off
+ this.htmlElement.video.controls = this.status.nativeVideoControls;
+ // Show/hide the jPlayer GUI.
+ this._updateAutohide();
+ // For when option changed. The poster image is not updated, as it is dealt with in setMedia(). Acceptable degradation since seriously doubt these options will change on the fly. Can again review later.
+ if(this.status.nativeVideoControls && this.require.video) {
+ this.internal.poster.jq.hide();
+ this.internal.video.jq.css({'width': this.status.width, 'height': this.status.height});
+ } else if(this.status.waitForPlay && this.status.video) {
+ this.internal.poster.jq.show();
+ this.internal.video.jq.css({'width': '0px', 'height': '0px'});
+ }
+ }
+ },
+ _addHtmlEventListeners: function(mediaElement, entity) {
+ var self = this;
+ mediaElement.preload = this.options.preload;
+ mediaElement.muted = this.options.muted;
+ mediaElement.volume = this.options.volume;
+
+ // Create the event listeners
+ // Only want the active entity to affect jPlayer and bubble events.
+ // Using entity.gate so that object is referenced and gate property always current
+
+ mediaElement.addEventListener("progress", function() {
+ if(entity.gate) {
+ self._getHtmlStatus(mediaElement);
+ self._updateInterface();
+ self._trigger($.jPlayer.event.progress);
+ }
+ }, false);
+ mediaElement.addEventListener("timeupdate", function() {
+ if(entity.gate) {
+ self._getHtmlStatus(mediaElement);
+ self._updateInterface();
+ self._trigger($.jPlayer.event.timeupdate);
+ }
+ }, false);
+ mediaElement.addEventListener("durationchange", function() {
+ if(entity.gate) {
+ self.status.duration = this.duration;
+ self._getHtmlStatus(mediaElement);
+ self._updateInterface();
+ self._trigger($.jPlayer.event.durationchange);
+ }
+ }, false);
+ mediaElement.addEventListener("play", function() {
+ if(entity.gate) {
+ self._updateButtons(true);
+ self._html_checkWaitForPlay(); // So the native controls update this variable and puts the hidden interface in the correct state. Affects toggling native controls.
+ self._trigger($.jPlayer.event.play);
+ }
+ }, false);
+ mediaElement.addEventListener("playing", function() {
+ if(entity.gate) {
+ self._updateButtons(true);
+ self._seeked();
+ self._trigger($.jPlayer.event.playing);
+ }
+ }, false);
+ mediaElement.addEventListener("pause", function() {
+ if(entity.gate) {
+ self._updateButtons(false);
+ self._trigger($.jPlayer.event.pause);
+ }
+ }, false);
+ mediaElement.addEventListener("waiting", function() {
+ if(entity.gate) {
+ self._seeking();
+ self._trigger($.jPlayer.event.waiting);
+ }
+ }, false);
+ mediaElement.addEventListener("seeking", function() {
+ if(entity.gate) {
+ self._seeking();
+ self._trigger($.jPlayer.event.seeking);
+ }
+ }, false);
+ mediaElement.addEventListener("seeked", function() {
+ if(entity.gate) {
+ self._seeked();
+ self._trigger($.jPlayer.event.seeked);
+ }
+ }, false);
+ mediaElement.addEventListener("volumechange", function() {
+ if(entity.gate) {
+ // Read the values back from the element as the Blackberry PlayBook shares the volume with the physical buttons master volume control.
+ // However, when tested 6th July 2011, those buttons do not generate an event. The physical play/pause button does though.
+ self.options.volume = mediaElement.volume;
+ self.options.muted = mediaElement.muted;
+ self._updateMute();
+ self._updateVolume();
+ self._trigger($.jPlayer.event.volumechange);
+ }
+ }, false);
+ mediaElement.addEventListener("suspend", function() { // Seems to be the only way of capturing that the iOS4 browser did not actually play the media from the page code. ie., It needs a user gesture.
+ if(entity.gate) {
+ self._seeked();
+ self._trigger($.jPlayer.event.suspend);
+ }
+ }, false);
+ mediaElement.addEventListener("ended", function() {
+ if(entity.gate) {
+ // Order of the next few commands are important. Change the time and then pause.
+ // Solves a bug in Firefox, where issuing pause 1st causes the media to play from the start. ie., The pause is ignored.
+ if(!$.jPlayer.browser.webkit) { // Chrome crashes if you do this in conjunction with a setMedia command in an ended event handler. ie., The playlist demo.
+ self.htmlElement.media.currentTime = 0; // Safari does not care about this command. ie., It works with or without this line. (Both Safari and Chrome are Webkit.)
+ }
+ self.htmlElement.media.pause(); // Pause otherwise a click on the progress bar will play from that point, when it shouldn't, since it stopped playback.
+ self._updateButtons(false);
+ self._getHtmlStatus(mediaElement, true); // With override true. Otherwise Chrome leaves progress at full.
+ self._updateInterface();
+ self._trigger($.jPlayer.event.ended);
+ }
+ }, false);
+ mediaElement.addEventListener("error", function() {
+ if(entity.gate) {
+ self._updateButtons(false);
+ self._seeked();
+ if(self.status.srcSet) { // Deals with case of clearMedia() causing an error event.
+ clearTimeout(self.internal.htmlDlyCmdId); // Clears any delayed commands used in the HTML solution.
+ self.status.waitForLoad = true; // Allows the load operation to try again.
+ self.status.waitForPlay = true; // Reset since a play was captured.
+ if(self.status.video && !self.status.nativeVideoControls) {
+ self.internal.video.jq.css({'width':'0px', 'height':'0px'});
+ }
+ if(self._validString(self.status.media.poster) && !self.status.nativeVideoControls) {
+ self.internal.poster.jq.show();
+ }
+ if(self.css.jq.videoPlay.length) {
+ self.css.jq.videoPlay.show();
+ }
+ self._error( {
+ type: $.jPlayer.error.URL,
+ context: self.status.src, // this.src shows absolute urls. Want context to show the url given.
+ message: $.jPlayer.errorMsg.URL,
+ hint: $.jPlayer.errorHint.URL
+ });
+ }
+ }
+ }, false);
+ // Create all the other event listeners that bubble up to a jPlayer event from html, without being used by jPlayer.
+ $.each($.jPlayer.htmlEvent, function(i, eventType) {
+ mediaElement.addEventListener(this, function() {
+ if(entity.gate) {
+ self._trigger($.jPlayer.event[eventType]);
+ }
+ }, false);
+ });
+ },
+ _getHtmlStatus: function(media, override) {
+ var ct = 0, d = 0, cpa = 0, sp = 0, cpr = 0;
+
+ if(media.duration) { // Fixes the duration bug in iOS, where the durationchange event occurs when media.duration is not always correct.
+ this.status.duration = media.duration;
+ }
+ ct = media.currentTime;
+ cpa = (this.status.duration > 0) ? 100 * ct / this.status.duration : 0;
+ if((typeof media.seekable === "object") && (media.seekable.length > 0)) {
+ sp = (this.status.duration > 0) ? 100 * media.seekable.end(media.seekable.length-1) / this.status.duration : 100;
+ cpr = 100 * media.currentTime / media.seekable.end(media.seekable.length-1);
+ } else {
+ sp = 100;
+ cpr = cpa;
+ }
+
+ if(override) {
+ ct = 0;
+ cpr = 0;
+ cpa = 0;
+ }
+
+ this.status.seekPercent = sp;
+ this.status.currentPercentRelative = cpr;
+ this.status.currentPercentAbsolute = cpa;
+ this.status.currentTime = ct;
+
+ this.status.readyState = media.readyState;
+ this.status.networkState = media.networkState;
+ this.status.playbackRate = media.playbackRate;
+ this.status.ended = media.ended;
+ },
+ _resetStatus: function() {
+ this.status = $.extend({}, this.status, $.jPlayer.prototype.status); // Maintains the status properties that persist through a reset.
+ },
+ _trigger: function(eventType, error, warning) { // eventType always valid as called using $.jPlayer.event.eventType
+ var event = $.Event(eventType);
+ event.jPlayer = {};
+ event.jPlayer.version = $.extend({}, this.version);
+ event.jPlayer.options = $.extend(true, {}, this.options); // Deep copy
+ event.jPlayer.status = $.extend(true, {}, this.status); // Deep copy
+ event.jPlayer.html = $.extend(true, {}, this.html); // Deep copy
+ event.jPlayer.flash = $.extend(true, {}, this.flash); // Deep copy
+ if(error) {
+ event.jPlayer.error = $.extend({}, error);
+ }
+ if(warning) {
+ event.jPlayer.warning = $.extend({}, warning);
+ }
+ this.element.trigger(event);
+ },
+ jPlayerFlashEvent: function(eventType, status) { // Called from Flash
+ if(eventType === $.jPlayer.event.ready) {
+ if(!this.internal.ready) {
+ this.internal.ready = true;
+ this.internal.flash.jq.css({'width':'0px', 'height':'0px'}); // Once Flash generates the ready event, minimise to zero as it is not affected by wmode anymore.
+
+ this.version.flash = status.version;
+ if(this.version.needFlash !== this.version.flash) {
+ this._error( {
+ type: $.jPlayer.error.VERSION,
+ context: this.version.flash,
+ message: $.jPlayer.errorMsg.VERSION + this.version.flash,
+ hint: $.jPlayer.errorHint.VERSION
+ });
+ }
+ this._trigger($.jPlayer.event.repeat); // Trigger the repeat event so its handler can initialize itself with the loop option.
+ this._trigger(eventType);
+ } else {
+ // This condition occurs if the Flash is hidden and then shown again.
+ // Firefox also reloads the Flash if the CSS position changes. position:fixed is used for full screen.
+
+ // Only do this if the Flash is the solution being used at the moment. Affects Media players where both solution may be being used.
+ if(this.flash.gate) {
+
+ // Send the current status to the Flash now that it is ready (available) again.
+ if(this.status.srcSet) {
+
+ // Need to read original status before issuing the setMedia command.
+ var currentTime = this.status.currentTime,
+ paused = this.status.paused;
+
+ this.setMedia(this.status.media);
+ if(currentTime > 0) {
+ if(paused) {
+ this.pause(currentTime);
+ } else {
+ this.play(currentTime);
+ }
+ }
+ }
+ this._trigger($.jPlayer.event.flashreset);
+ }
+ }
+ }
+ if(this.flash.gate) {
+ switch(eventType) {
+ case $.jPlayer.event.progress:
+ this._getFlashStatus(status);
+ this._updateInterface();
+ this._trigger(eventType);
+ break;
+ case $.jPlayer.event.timeupdate:
+ this._getFlashStatus(status);
+ this._updateInterface();
+ this._trigger(eventType);
+ break;
+ case $.jPlayer.event.play:
+ this._seeked();
+ this._updateButtons(true);
+ this._trigger(eventType);
+ break;
+ case $.jPlayer.event.pause:
+ this._updateButtons(false);
+ this._trigger(eventType);
+ break;
+ case $.jPlayer.event.ended:
+ this._updateButtons(false);
+ this._trigger(eventType);
+ break;
+ case $.jPlayer.event.click:
+ this._trigger(eventType); // This could be dealt with by the default
+ break;
+ case $.jPlayer.event.error:
+ this.status.waitForLoad = true; // Allows the load operation to try again.
+ this.status.waitForPlay = true; // Reset since a play was captured.
+ if(this.status.video) {
+ this.internal.flash.jq.css({'width':'0px', 'height':'0px'});
+ }
+ if(this._validString(this.status.media.poster)) {
+ this.internal.poster.jq.show();
+ }
+ if(this.css.jq.videoPlay.length && this.status.video) {
+ this.css.jq.videoPlay.show();
+ }
+ if(this.status.video) { // Set up for another try. Execute before error event.
+ this._flash_setVideo(this.status.media);
+ } else {
+ this._flash_setAudio(this.status.media);
+ }
+ this._updateButtons(false);
+ this._error( {
+ type: $.jPlayer.error.URL,
+ context:status.src,
+ message: $.jPlayer.errorMsg.URL,
+ hint: $.jPlayer.errorHint.URL
+ });
+ break;
+ case $.jPlayer.event.seeking:
+ this._seeking();
+ this._trigger(eventType);
+ break;
+ case $.jPlayer.event.seeked:
+ this._seeked();
+ this._trigger(eventType);
+ break;
+ case $.jPlayer.event.ready:
+ // The ready event is handled outside the switch statement.
+ // Captured here otherwise 2 ready events would be generated if the ready event handler used setMedia.
+ break;
+ default:
+ this._trigger(eventType);
+ }
+ }
+ return false;
+ },
+ _getFlashStatus: function(status) {
+ this.status.seekPercent = status.seekPercent;
+ this.status.currentPercentRelative = status.currentPercentRelative;
+ this.status.currentPercentAbsolute = status.currentPercentAbsolute;
+ this.status.currentTime = status.currentTime;
+ this.status.duration = status.duration;
+
+ // The Flash does not generate this information in this release
+ this.status.readyState = 4; // status.readyState;
+ this.status.networkState = 0; // status.networkState;
+ this.status.playbackRate = 1; // status.playbackRate;
+ this.status.ended = false; // status.ended;
+ },
+ _updateButtons: function(playing) {
+ if(playing !== undefined) {
+ this.status.paused = !playing;
+ if(this.css.jq.play.length && this.css.jq.pause.length) {
+ if(playing) {
+ this.css.jq.play.hide();
+ this.css.jq.pause.show();
+ } else {
+ this.css.jq.play.show();
+ this.css.jq.pause.hide();
+ }
+ }
+ }
+ if(this.css.jq.restoreScreen.length && this.css.jq.fullScreen.length) {
+ if(this.status.noFullScreen) {
+ this.css.jq.fullScreen.hide();
+ this.css.jq.restoreScreen.hide();
+ } else if(this.options.fullScreen) {
+ this.css.jq.fullScreen.hide();
+ this.css.jq.restoreScreen.show();
+ } else {
+ this.css.jq.fullScreen.show();
+ this.css.jq.restoreScreen.hide();
+ }
+ }
+ if(this.css.jq.repeat.length && this.css.jq.repeatOff.length) {
+ if(this.options.loop) {
+ this.css.jq.repeat.hide();
+ this.css.jq.repeatOff.show();
+ } else {
+ this.css.jq.repeat.show();
+ this.css.jq.repeatOff.hide();
+ }
+ }
+ },
+ _updateInterface: function() {
+ if(this.css.jq.seekBar.length) {
+ this.css.jq.seekBar.width(this.status.seekPercent+"%");
+ }
+ if(this.css.jq.playBar.length) {
+ this.css.jq.playBar.width(this.status.currentPercentRelative+"%");
+ }
+ if(this.css.jq.currentTime.length) {
+ this.css.jq.currentTime.text($.jPlayer.convertTime(this.status.currentTime));
+ }
+ if(this.css.jq.duration.length) {
+ this.css.jq.duration.text($.jPlayer.convertTime(this.status.duration));
+ }
+ },
+ _seeking: function() {
+ if(this.css.jq.seekBar.length) {
+ this.css.jq.seekBar.addClass("jp-seeking-bg");
+ }
+ },
+ _seeked: function() {
+ if(this.css.jq.seekBar.length) {
+ this.css.jq.seekBar.removeClass("jp-seeking-bg");
+ }
+ },
+ _resetGate: function() {
+ this.html.audio.gate = false;
+ this.html.video.gate = false;
+ this.flash.gate = false;
+ },
+ _resetActive: function() {
+ this.html.active = false;
+ this.flash.active = false;
+ },
+ setMedia: function(media) {
+
+ /* media[format] = String: URL of format. Must contain all of the supplied option's video or audio formats.
+ * media.poster = String: Video poster URL.
+ * media.subtitles = String: * NOT IMPLEMENTED * URL of subtitles SRT file
+ * media.chapters = String: * NOT IMPLEMENTED * URL of chapters SRT file
+ * media.stream = Boolean: * NOT IMPLEMENTED * Designating actual media streams. ie., "false/undefined" for files. Plan to refresh the flash every so often.
+ */
+
+ var self = this,
+ supported = false,
+ posterChanged = this.status.media.poster !== media.poster; // Compare before reset. Important for OSX Safari as this.htmlElement.poster.src is absolute, even if original poster URL was relative.
+
+ this._resetMedia();
+ this._resetGate();
+ this._resetActive();
+
+ $.each(this.formats, function(formatPriority, format) {
+ var isVideo = self.format[format].media === 'video';
+ $.each(self.solutions, function(solutionPriority, solution) {
+ if(self[solution].support[format] && self._validString(media[format])) { // Format supported in solution and url given for format.
+ var isHtml = solution === 'html';
+
+ if(isVideo) {
+ if(isHtml) {
+ self.html.video.gate = true;
+ self._html_setVideo(media);
+ self.html.active = true;
+ } else {
+ self.flash.gate = true;
+ self._flash_setVideo(media);
+ self.flash.active = true;
+ }
+ if(self.css.jq.videoPlay.length) {
+ self.css.jq.videoPlay.show();
+ }
+ self.status.video = true;
+ } else {
+ if(isHtml) {
+ self.html.audio.gate = true;
+ self._html_setAudio(media);
+ self.html.active = true;
+ } else {
+ self.flash.gate = true;
+ self._flash_setAudio(media);
+ self.flash.active = true;
+ }
+ if(self.css.jq.videoPlay.length) {
+ self.css.jq.videoPlay.hide();
+ }
+ self.status.video = false;
+ }
+
+ supported = true;
+ return false; // Exit $.each
+ }
+ });
+ if(supported) {
+ return false; // Exit $.each
+ }
+ });
+
+ if(supported) {
+ if(!(this.status.nativeVideoControls && this.html.video.gate)) {
+ // Set poster IMG if native video controls are not being used
+ // Note: With IE the IMG onload event occurs immediately when cached.
+ // Note: Poster hidden by default in _resetMedia()
+ if(this._validString(media.poster)) {
+ if(posterChanged) { // Since some browsers do not generate img onload event.
+ this.htmlElement.poster.src = media.poster;
+ } else {
+ this.internal.poster.jq.show();
+ }
+ }
+ }
+ this.status.srcSet = true;
+ this.status.media = $.extend({}, media);
+ this._updateButtons(false);
+ this._updateInterface();
+ } else { // jPlayer cannot support any formats provided in this browser
+ // Send an error event
+ this._error( {
+ type: $.jPlayer.error.NO_SUPPORT,
+ context: "{supplied:'" + this.options.supplied + "'}",
+ message: $.jPlayer.errorMsg.NO_SUPPORT,
+ hint: $.jPlayer.errorHint.NO_SUPPORT
+ });
+ }
+ },
+ _resetMedia: function() {
+ this._resetStatus();
+ this._updateButtons(false);
+ this._updateInterface();
+ this._seeked();
+ this.internal.poster.jq.hide();
+
+ clearTimeout(this.internal.htmlDlyCmdId);
+
+ if(this.html.active) {
+ this._html_resetMedia();
+ } else if(this.flash.active) {
+ this._flash_resetMedia();
+ }
+ },
+ clearMedia: function() {
+ this._resetMedia();
+
+ if(this.html.active) {
+ this._html_clearMedia();
+ } else if(this.flash.active) {
+ this._flash_clearMedia();
+ }
+
+ this._resetGate();
+ this._resetActive();
+ },
+ load: function() {
+ if(this.status.srcSet) {
+ if(this.html.active) {
+ this._html_load();
+ } else if(this.flash.active) {
+ this._flash_load();
+ }
+ } else {
+ this._urlNotSetError("load");
+ }
+ },
+ play: function(time) {
+ time = (typeof time === "number") ? time : NaN; // Remove jQuery event from click handler
+ if(this.status.srcSet) {
+ if(this.html.active) {
+ this._html_play(time);
+ } else if(this.flash.active) {
+ this._flash_play(time);
+ }
+ } else {
+ this._urlNotSetError("play");
+ }
+ },
+ videoPlay: function(e) { // Handles clicks on the play button over the video poster
+ this.play();
+ },
+ pause: function(time) {
+ time = (typeof time === "number") ? time : NaN; // Remove jQuery event from click handler
+ if(this.status.srcSet) {
+ if(this.html.active) {
+ this._html_pause(time);
+ } else if(this.flash.active) {
+ this._flash_pause(time);
+ }
+ } else {
+ this._urlNotSetError("pause");
+ }
+ },
+ pauseOthers: function() {
+ var self = this;
+ $.each(this.instances, function(i, element) {
+ if(self.element !== element) { // Do not this instance.
+ if(element.data("jPlayer").status.srcSet) { // Check that media is set otherwise would cause error event.
+ element.jPlayer("pause");
+ }
+ }
+ });
+ },
+ stop: function() {
+ if(this.status.srcSet) {
+ if(this.html.active) {
+ this._html_pause(0);
+ } else if(this.flash.active) {
+ this._flash_pause(0);
+ }
+ } else {
+ this._urlNotSetError("stop");
+ }
+ },
+ playHead: function(p) {
+ p = this._limitValue(p, 0, 100);
+ if(this.status.srcSet) {
+ if(this.html.active) {
+ this._html_playHead(p);
+ } else if(this.flash.active) {
+ this._flash_playHead(p);
+ }
+ } else {
+ this._urlNotSetError("playHead");
+ }
+ },
+ _muted: function(muted) {
+ this.options.muted = muted;
+ if(this.html.used) {
+ this._html_mute(muted);
+ }
+ if(this.flash.used) {
+ this._flash_mute(muted);
+ }
+
+ // The HTML solution generates this event from the media element itself.
+ if(!this.html.video.gate && !this.html.audio.gate) {
+ this._updateMute(muted);
+ this._updateVolume(this.options.volume);
+ this._trigger($.jPlayer.event.volumechange);
+ }
+ },
+ mute: function(mute) { // mute is either: undefined (true), an event object (true) or a boolean (muted).
+ mute = mute === undefined ? true : !!mute;
+ this._muted(mute);
+ },
+ unmute: function(unmute) { // unmute is either: undefined (true), an event object (true) or a boolean (!muted).
+ unmute = unmute === undefined ? true : !!unmute;
+ this._muted(!unmute);
+ },
+ _updateMute: function(mute) {
+ if(mute === undefined) {
+ mute = this.options.muted;
+ }
+ if(this.css.jq.mute.length && this.css.jq.unmute.length) {
+ if(this.status.noVolume) {
+ this.css.jq.mute.hide();
+ this.css.jq.unmute.hide();
+ } else if(mute) {
+ this.css.jq.mute.hide();
+ this.css.jq.unmute.show();
+ } else {
+ this.css.jq.mute.show();
+ this.css.jq.unmute.hide();
+ }
+ }
+ },
+ volume: function(v) {
+ v = this._limitValue(v, 0, 1);
+ this.options.volume = v;
+
+ if(this.html.used) {
+ this._html_volume(v);
+ }
+ if(this.flash.used) {
+ this._flash_volume(v);
+ }
+
+ // The HTML solution generates this event from the media element itself.
+ if(!this.html.video.gate && !this.html.audio.gate) {
+ this._updateVolume(v);
+ this._trigger($.jPlayer.event.volumechange);
+ }
+ },
+ volumeBar: function(e) { // Handles clicks on the volumeBar
+ if(this.css.jq.volumeBar.length) {
+ var offset = this.css.jq.volumeBar.offset(),
+ x = e.pageX - offset.left,
+ w = this.css.jq.volumeBar.width(),
+ y = this.css.jq.volumeBar.height() - e.pageY + offset.top,
+ h = this.css.jq.volumeBar.height();
+
+ if(this.options.verticalVolume) {
+ this.volume(y/h);
+ } else {
+ this.volume(x/w);
+ }
+ }
+ if(this.options.muted) {
+ this._muted(false);
+ }
+ },
+ volumeBarValue: function(e) { // Handles clicks on the volumeBarValue
+ this.volumeBar(e);
+ },
+ _updateVolume: function(v) {
+ if(v === undefined) {
+ v = this.options.volume;
+ }
+ v = this.options.muted ? 0 : v;
+
+ if(this.status.noVolume) {
+ if(this.css.jq.volumeBar.length) {
+ this.css.jq.volumeBar.hide();
+ }
+ if(this.css.jq.volumeBarValue.length) {
+ this.css.jq.volumeBarValue.hide();
+ }
+ if(this.css.jq.volumeMax.length) {
+ this.css.jq.volumeMax.hide();
+ }
+ } else {
+ if(this.css.jq.volumeBar.length) {
+ this.css.jq.volumeBar.show();
+ }
+ if(this.css.jq.volumeBarValue.length) {
+ this.css.jq.volumeBarValue.show();
+ this.css.jq.volumeBarValue[this.options.verticalVolume ? "height" : "width"]((v*100)+"%");
+ }
+ if(this.css.jq.volumeMax.length) {
+ this.css.jq.volumeMax.show();
+ }
+ }
+ },
+ volumeMax: function() { // Handles clicks on the volume max
+ this.volume(1);
+ if(this.options.muted) {
+ this._muted(false);
+ }
+ },
+ _cssSelectorAncestor: function(ancestor) {
+ var self = this;
+ this.options.cssSelectorAncestor = ancestor;
+ this._removeUiClass();
+ this.ancestorJq = ancestor ? $(ancestor) : []; // Would use $() instead of [], but it is only 1.4+
+ if(ancestor && this.ancestorJq.length !== 1) { // So empty strings do not generate the warning.
+ this._warning( {
+ type: $.jPlayer.warning.CSS_SELECTOR_COUNT,
+ context: ancestor,
+ message: $.jPlayer.warningMsg.CSS_SELECTOR_COUNT + this.ancestorJq.length + " found for cssSelectorAncestor.",
+ hint: $.jPlayer.warningHint.CSS_SELECTOR_COUNT
+ });
+ }
+ this._addUiClass();
+ $.each(this.options.cssSelector, function(fn, cssSel) {
+ self._cssSelector(fn, cssSel);
+ });
+ },
+ _cssSelector: function(fn, cssSel) {
+ var self = this;
+ if(typeof cssSel === 'string') {
+ if($.jPlayer.prototype.options.cssSelector[fn]) {
+ if(this.css.jq[fn] && this.css.jq[fn].length) {
+ this.css.jq[fn].unbind(".jPlayer");
+ }
+ this.options.cssSelector[fn] = cssSel;
+ this.css.cs[fn] = this.options.cssSelectorAncestor + " " + cssSel;
+
+ if(cssSel) { // Checks for empty string
+ this.css.jq[fn] = $(this.css.cs[fn]);
+ } else {
+ this.css.jq[fn] = []; // To comply with the css.jq[fn].length check before its use. As of jQuery 1.4 could have used $() for an empty set.
+ }
+
+ if(this.css.jq[fn].length) {
+ var handler = function(e) {
+ self[fn](e);
+ $(this).blur();
+ return false;
+ };
+ this.css.jq[fn].bind("click.jPlayer", handler); // Using jPlayer namespace
+ }
+
+ if(cssSel && this.css.jq[fn].length !== 1) { // So empty strings do not generate the warning. ie., they just remove the old one.
+ this._warning( {
+ type: $.jPlayer.warning.CSS_SELECTOR_COUNT,
+ context: this.css.cs[fn],
+ message: $.jPlayer.warningMsg.CSS_SELECTOR_COUNT + this.css.jq[fn].length + " found for " + fn + " method.",
+ hint: $.jPlayer.warningHint.CSS_SELECTOR_COUNT
+ });
+ }
+ } else {
+ this._warning( {
+ type: $.jPlayer.warning.CSS_SELECTOR_METHOD,
+ context: fn,
+ message: $.jPlayer.warningMsg.CSS_SELECTOR_METHOD,
+ hint: $.jPlayer.warningHint.CSS_SELECTOR_METHOD
+ });
+ }
+ } else {
+ this._warning( {
+ type: $.jPlayer.warning.CSS_SELECTOR_STRING,
+ context: cssSel,
+ message: $.jPlayer.warningMsg.CSS_SELECTOR_STRING,
+ hint: $.jPlayer.warningHint.CSS_SELECTOR_STRING
+ });
+ }
+ },
+ seekBar: function(e) { // Handles clicks on the seekBar
+ if(this.css.jq.seekBar) {
+ var offset = this.css.jq.seekBar.offset();
+ var x = e.pageX - offset.left;
+ var w = this.css.jq.seekBar.width();
+ var p = 100*x/w;
+ this.playHead(p);
+ }
+ },
+ playBar: function(e) { // Handles clicks on the playBar
+ this.seekBar(e);
+ },
+ repeat: function() { // Handle clicks on the repeat button
+ this._loop(true);
+ },
+ repeatOff: function() { // Handle clicks on the repeatOff button
+ this._loop(false);
+ },
+ _loop: function(loop) {
+ if(this.options.loop !== loop) {
+ this.options.loop = loop;
+ this._updateButtons();
+ this._trigger($.jPlayer.event.repeat);
+ }
+ },
+
+ // Plan to review the cssSelector method to cope with missing associated functions accordingly.
+
+ currentTime: function(e) { // Handles clicks on the text
+ // Added to avoid errors using cssSelector system for the text
+ },
+ duration: function(e) { // Handles clicks on the text
+ // Added to avoid errors using cssSelector system for the text
+ },
+ gui: function(e) { // Handles clicks on the gui
+ // Added to avoid errors using cssSelector system for the gui
+ },
+ noSolution: function(e) { // Handles clicks on the error message
+ // Added to avoid errors using cssSelector system for no-solution
+ },
+
+ // Options code adapted from ui.widget.js (1.8.7). Made changes so the key can use dot notation. To match previous getData solution in jPlayer 1.
+ option: function(key, value) {
+ var options = key;
+
+ // Enables use: options(). Returns a copy of options object
+ if ( arguments.length === 0 ) {
+ return $.extend( true, {}, this.options );
+ }
+
+ if(typeof key === "string") {
+ var keys = key.split(".");
+
+ // Enables use: options("someOption") Returns a copy of the option. Supports dot notation.
+ if(value === undefined) {
+
+ var opt = $.extend(true, {}, this.options);
+ for(var i = 0; i < keys.length; i++) {
+ if(opt[keys[i]] !== undefined) {
+ opt = opt[keys[i]];
+ } else {
+ this._warning( {
+ type: $.jPlayer.warning.OPTION_KEY,
+ context: key,
+ message: $.jPlayer.warningMsg.OPTION_KEY,
+ hint: $.jPlayer.warningHint.OPTION_KEY
+ });
+ return undefined;
+ }
+ }
+ return opt;
+ }
+
+ // Enables use: options("someOptionObject", someObject}). Creates: {someOptionObject:someObject}
+ // Enables use: options("someOption", someValue). Creates: {someOption:someValue}
+ // Enables use: options("someOptionObject.someOption", someValue). Creates: {someOptionObject:{someOption:someValue}}
+
+ options = {};
+ var opts = options;
+
+ for(var j = 0; j < keys.length; j++) {
+ if(j < keys.length - 1) {
+ opts[keys[j]] = {};
+ opts = opts[keys[j]];
+ } else {
+ opts[keys[j]] = value;
+ }
+ }
+ }
+
+ // Otherwise enables use: options(optionObject). Uses original object (the key)
+
+ this._setOptions(options);
+
+ return this;
+ },
+ _setOptions: function(options) {
+ var self = this;
+ $.each(options, function(key, value) { // This supports the 2 level depth that the options of jPlayer has. Would review if we ever need more depth.
+ self._setOption(key, value);
+ });
+
+ return this;
+ },
+ _setOption: function(key, value) {
+ var self = this;
+
+ // The ability to set options is limited at this time.
+
+ switch(key) {
+ case "volume" :
+ this.volume(value);
+ break;
+ case "muted" :
+ this._muted(value);
+ break;
+ case "cssSelectorAncestor" :
+ this._cssSelectorAncestor(value); // Set and refresh all associations for the new ancestor.
+ break;
+ case "cssSelector" :
+ $.each(value, function(fn, cssSel) {
+ self._cssSelector(fn, cssSel); // NB: The option is set inside this function, after further validity checks.
+ });
+ break;
+ case "fullScreen" :
+ if(this.options[key] !== value) { // if changed
+ this._removeUiClass();
+ this.options[key] = value;
+ this._refreshSize();
+ }
+ break;
+ case "size" :
+ if(!this.options.fullScreen && this.options[key].cssClass !== value.cssClass) {
+ this._removeUiClass();
+ }
+ this.options[key] = $.extend({}, this.options[key], value); // store a merged copy of it, incase not all properties changed.
+ this._refreshSize();
+ break;
+ case "sizeFull" :
+ if(this.options.fullScreen && this.options[key].cssClass !== value.cssClass) {
+ this._removeUiClass();
+ }
+ this.options[key] = $.extend({}, this.options[key], value); // store a merged copy of it, incase not all properties changed.
+ this._refreshSize();
+ break;
+ case "autohide" :
+ this.options[key] = $.extend({}, this.options[key], value); // store a merged copy of it, incase not all properties changed.
+ this._updateAutohide();
+ break;
+ case "loop" :
+ this._loop(value);
+ break;
+ case "nativeVideoControls" :
+ this.options[key] = $.extend({}, this.options[key], value); // store a merged copy of it, incase not all properties changed.
+ this.status.nativeVideoControls = this._uaBlocklist(this.options.nativeVideoControls);
+ this._restrictNativeVideoControls();
+ this._updateNativeVideoControls();
+ break;
+ case "noFullScreen" :
+ this.options[key] = $.extend({}, this.options[key], value); // store a merged copy of it, incase not all properties changed.
+ this.status.nativeVideoControls = this._uaBlocklist(this.options.nativeVideoControls); // Need to check again as noFullScreen can depend on this flag and the restrict() can override it.
+ this.status.noFullScreen = this._uaBlocklist(this.options.noFullScreen);
+ this._restrictNativeVideoControls();
+ this._updateButtons();
+ break;
+ case "noVolume" :
+ this.options[key] = $.extend({}, this.options[key], value); // store a merged copy of it, incase not all properties changed.
+ this.status.noVolume = this._uaBlocklist(this.options.noVolume);
+ this._updateVolume();
+ this._updateMute();
+ break;
+ case "emulateHtml" :
+ if(this.options[key] !== value) { // To avoid multiple event handlers being created, if true already.
+ this.options[key] = value;
+ if(value) {
+ this._emulateHtmlBridge();
+ } else {
+ this._destroyHtmlBridge();
+ }
+ }
+ break;
+ }
+
+ return this;
+ },
+ // End of: (Options code adapted from ui.widget.js)
+
+ _refreshSize: function() {
+ this._setSize(); // update status and jPlayer element size
+ this._addUiClass(); // update the ui class
+ this._updateSize(); // update internal sizes
+ this._updateButtons();
+ this._updateAutohide();
+ this._trigger($.jPlayer.event.resize);
+ },
+ _setSize: function() {
+ // Determine the current size from the options
+ if(this.options.fullScreen) {
+ this.status.width = this.options.sizeFull.width;
+ this.status.height = this.options.sizeFull.height;
+ this.status.cssClass = this.options.sizeFull.cssClass;
+ } else {
+ this.status.width = this.options.size.width;
+ this.status.height = this.options.size.height;
+ this.status.cssClass = this.options.size.cssClass;
+ }
+
+ // Set the size of the jPlayer area.
+ this.element.css({'width': this.status.width, 'height': this.status.height});
+ },
+ _addUiClass: function() {
+ if(this.ancestorJq.length) {
+ this.ancestorJq.addClass(this.status.cssClass);
+ }
+ },
+ _removeUiClass: function() {
+ if(this.ancestorJq.length) {
+ this.ancestorJq.removeClass(this.status.cssClass);
+ }
+ },
+ _updateSize: function() {
+ // The poster uses show/hide so can simply resize it.
+ this.internal.poster.jq.css({'width': this.status.width, 'height': this.status.height});
+
+ // Video html or flash resized if necessary at this time, or if native video controls being used.
+ if(!this.status.waitForPlay && this.html.active && this.status.video || this.html.video.available && this.html.used && this.status.nativeVideoControls) {
+ this.internal.video.jq.css({'width': this.status.width, 'height': this.status.height});
+ }
+ else if(!this.status.waitForPlay && this.flash.active && this.status.video) {
+ this.internal.flash.jq.css({'width': this.status.width, 'height': this.status.height});
+ }
+ },
+ _updateAutohide: function() {
+ var self = this,
+ event = "mousemove.jPlayer",
+ namespace = ".jPlayerAutohide",
+ eventType = event + namespace,
+ handler = function() {
+ self.css.jq.gui.fadeIn(self.options.autohide.fadeIn, function() {
+ clearTimeout(self.internal.autohideId);
+ self.internal.autohideId = setTimeout( function() {
+ self.css.jq.gui.fadeOut(self.options.autohide.fadeOut);
+ }, self.options.autohide.hold);
+ });
+ };
+
+ if(this.css.jq.gui.length) {
+
+ // End animations first so that its callback is executed now.
+ // Otherwise an in progress fadeIn animation still has the callback to fadeOut again.
+ this.css.jq.gui.stop(true, true);
+
+ // Removes the fadeOut operation from the fadeIn callback.
+ clearTimeout(this.internal.autohideId);
+
+ this.element.unbind(namespace);
+ this.css.jq.gui.unbind(namespace);
+
+ if(!this.status.nativeVideoControls) {
+ if(this.options.fullScreen && this.options.autohide.full || !this.options.fullScreen && this.options.autohide.restored) {
+ this.element.bind(eventType, handler);
+ this.css.jq.gui.bind(eventType, handler);
+ this.css.jq.gui.hide();
+ } else {
+ this.css.jq.gui.show();
+ }
+ } else {
+ this.css.jq.gui.hide();
+ }
+ }
+ },
+ fullScreen: function() {
+ this._setOption("fullScreen", true);
+ },
+ restoreScreen: function() {
+ this._setOption("fullScreen", false);
+ },
+ _html_initMedia: function() {
+ this.htmlElement.media.src = this.status.src;
+
+ if(this.options.preload !== 'none') {
+ this._html_load(); // See function for comments
+ }
+ this._trigger($.jPlayer.event.timeupdate); // The flash generates this event for its solution.
+ },
+ _html_setAudio: function(media) {
+ var self = this;
+ // Always finds a format due to checks in setMedia()
+ $.each(this.formats, function(priority, format) {
+ if(self.html.support[format] && media[format]) {
+ self.status.src = media[format];
+ self.status.format[format] = true;
+ self.status.formatType = format;
+ return false;
+ }
+ });
+ this.htmlElement.media = this.htmlElement.audio;
+ this._html_initMedia();
+ },
+ _html_setVideo: function(media) {
+ var self = this;
+ // Always finds a format due to checks in setMedia()
+ $.each(this.formats, function(priority, format) {
+ if(self.html.support[format] && media[format]) {
+ self.status.src = media[format];
+ self.status.format[format] = true;
+ self.status.formatType = format;
+ return false;
+ }
+ });
+ if(this.status.nativeVideoControls) {
+ this.htmlElement.video.poster = this._validString(media.poster) ? media.poster : "";
+ }
+ this.htmlElement.media = this.htmlElement.video;
+ this._html_initMedia();
+ },
+ _html_resetMedia: function() {
+ if(this.htmlElement.media) {
+ if(this.htmlElement.media.id === this.internal.video.id && !this.status.nativeVideoControls) {
+ this.internal.video.jq.css({'width':'0px', 'height':'0px'});
+ }
+ this.htmlElement.media.pause();
+ }
+ },
+ _html_clearMedia: function() {
+ if(this.htmlElement.media) {
+ this.htmlElement.media.src = "";
+ this.htmlElement.media.load(); // Stops an old, "in progress" download from continuing the download. Triggers the loadstart, error and emptied events, due to the empty src. Also an abort event if a download was in progress.
+ }
+ },
+ _html_load: function() {
+ // This function remains to allow the early HTML5 browsers to work, such as Firefox 3.6
+ // A change in the W3C spec for the media.load() command means that this is no longer necessary.
+ // This command should be removed and actually causes minor undesirable effects on some browsers. Such as loading the whole file and not only the metadata.
+ if(this.status.waitForLoad) {
+ this.status.waitForLoad = false;
+ this.htmlElement.media.load();
+ }
+ clearTimeout(this.internal.htmlDlyCmdId);
+ },
+ _html_play: function(time) {
+ var self = this;
+ this._html_load(); // Loads if required and clears any delayed commands.
+
+ this.htmlElement.media.play(); // Before currentTime attempt otherwise Firefox 4 Beta never loads.
+
+ if(!isNaN(time)) {
+ try {
+ this.htmlElement.media.currentTime = time;
+ } catch(err) {
+ this.internal.htmlDlyCmdId = setTimeout(function() {
+ self.play(time);
+ }, 100);
+ return; // Cancel execution and wait for the delayed command.
+ }
+ }
+ this._html_checkWaitForPlay();
+ },
+ _html_pause: function(time) {
+ var self = this;
+
+ if(time > 0) { // We do not want the stop() command, which does pause(0), causing a load operation.
+ this._html_load(); // Loads if required and clears any delayed commands.
+ } else {
+ clearTimeout(this.internal.htmlDlyCmdId);
+ }
+
+ // Order of these commands is important for Safari (Win) and IE9. Pause then change currentTime.
+ this.htmlElement.media.pause();
+
+ if(!isNaN(time)) {
+ try {
+ this.htmlElement.media.currentTime = time;
+ } catch(err) {
+ this.internal.htmlDlyCmdId = setTimeout(function() {
+ self.pause(time);
+ }, 100);
+ return; // Cancel execution and wait for the delayed command.
+ }
+ }
+ if(time > 0) { // Avoids a setMedia() followed by stop() or pause(0) hiding the video play button.
+ this._html_checkWaitForPlay();
+ }
+ },
+ _html_playHead: function(percent) {
+ var self = this;
+ this._html_load(); // Loads if required and clears any delayed commands.
+ try {
+ if((typeof this.htmlElement.media.seekable === "object") && (this.htmlElement.media.seekable.length > 0)) {
+ this.htmlElement.media.currentTime = percent * this.htmlElement.media.seekable.end(this.htmlElement.media.seekable.length-1) / 100;
+ } else if(this.htmlElement.media.duration > 0 && !isNaN(this.htmlElement.media.duration)) {
+ this.htmlElement.media.currentTime = percent * this.htmlElement.media.duration / 100;
+ } else {
+ throw "e";
+ }
+ } catch(err) {
+ this.internal.htmlDlyCmdId = setTimeout(function() {
+ self.playHead(percent);
+ }, 100);
+ return; // Cancel execution and wait for the delayed command.
+ }
+ if(!this.status.waitForLoad) {
+ this._html_checkWaitForPlay();
+ }
+ },
+ _html_checkWaitForPlay: function() {
+ if(this.status.waitForPlay) {
+ this.status.waitForPlay = false;
+ if(this.css.jq.videoPlay.length) {
+ this.css.jq.videoPlay.hide();
+ }
+ if(this.status.video) {
+ this.internal.poster.jq.hide();
+ this.internal.video.jq.css({'width': this.status.width, 'height': this.status.height});
+ }
+ }
+ },
+ _html_volume: function(v) {
+ if(this.html.audio.available) {
+ this.htmlElement.audio.volume = v;
+ }
+ if(this.html.video.available) {
+ this.htmlElement.video.volume = v;
+ }
+ },
+ _html_mute: function(m) {
+ if(this.html.audio.available) {
+ this.htmlElement.audio.muted = m;
+ }
+ if(this.html.video.available) {
+ this.htmlElement.video.muted = m;
+ }
+ },
+ _flash_setAudio: function(media) {
+ var self = this;
+ try {
+ // Always finds a format due to checks in setMedia()
+ $.each(this.formats, function(priority, format) {
+ if(self.flash.support[format] && media[format]) {
+ switch (format) {
+ case "m4a" :
+ case "fla" :
+ self._getMovie().fl_setAudio_m4a(media[format]);
+ break;
+ case "mp3" :
+ self._getMovie().fl_setAudio_mp3(media[format]);
+ break;
+ }
+ self.status.src = media[format];
+ self.status.format[format] = true;
+ self.status.formatType = format;
+ return false;
+ }
+ });
+
+ if(this.options.preload === 'auto') {
+ this._flash_load();
+ this.status.waitForLoad = false;
+ }
+ } catch(err) { this._flashError(err); }
+ },
+ _flash_setVideo: function(media) {
+ var self = this;
+ try {
+ // Always finds a format due to checks in setMedia()
+ $.each(this.formats, function(priority, format) {
+ if(self.flash.support[format] && media[format]) {
+ switch (format) {
+ case "m4v" :
+ case "flv" :
+ self._getMovie().fl_setVideo_m4v(media[format]);
+ break;
+ }
+ self.status.src = media[format];
+ self.status.format[format] = true;
+ self.status.formatType = format;
+ return false;
+ }
+ });
+
+ if(this.options.preload === 'auto') {
+ this._flash_load();
+ this.status.waitForLoad = false;
+ }
+ } catch(err) { this._flashError(err); }
+ },
+ _flash_resetMedia: function() {
+ this.internal.flash.jq.css({'width':'0px', 'height':'0px'}); // Must do via CSS as setting attr() to zero causes a jQuery error in IE.
+ this._flash_pause(NaN);
+ },
+ _flash_clearMedia: function() {
+ try {
+ this._getMovie().fl_clearMedia();
+ } catch(err) { this._flashError(err); }
+ },
+ _flash_load: function() {
+ try {
+ this._getMovie().fl_load();
+ } catch(err) { this._flashError(err); }
+ this.status.waitForLoad = false;
+ },
+ _flash_play: function(time) {
+ try {
+ this._getMovie().fl_play(time);
+ } catch(err) { this._flashError(err); }
+ this.status.waitForLoad = false;
+ this._flash_checkWaitForPlay();
+ },
+ _flash_pause: function(time) {
+ try {
+ this._getMovie().fl_pause(time);
+ } catch(err) { this._flashError(err); }
+ if(time > 0) { // Avoids a setMedia() followed by stop() or pause(0) hiding the video play button.
+ this.status.waitForLoad = false;
+ this._flash_checkWaitForPlay();
+ }
+ },
+ _flash_playHead: function(p) {
+ try {
+ this._getMovie().fl_play_head(p);
+ } catch(err) { this._flashError(err); }
+ if(!this.status.waitForLoad) {
+ this._flash_checkWaitForPlay();
+ }
+ },
+ _flash_checkWaitForPlay: function() {
+ if(this.status.waitForPlay) {
+ this.status.waitForPlay = false;
+ if(this.css.jq.videoPlay.length) {
+ this.css.jq.videoPlay.hide();
+ }
+ if(this.status.video) {
+ this.internal.poster.jq.hide();
+ this.internal.flash.jq.css({'width': this.status.width, 'height': this.status.height});
+ }
+ }
+ },
+ _flash_volume: function(v) {
+ try {
+ this._getMovie().fl_volume(v);
+ } catch(err) { this._flashError(err); }
+ },
+ _flash_mute: function(m) {
+ try {
+ this._getMovie().fl_mute(m);
+ } catch(err) { this._flashError(err); }
+ },
+ _getMovie: function() {
+ return document[this.internal.flash.id];
+ },
+ _checkForFlash: function (version) {
+ // Function checkForFlash adapted from FlashReplace by Robert Nyman
+ // http://code.google.com/p/flashreplace/
+ var flashIsInstalled = false;
+ var flash;
+ if(window.ActiveXObject){
+ try{
+ flash = new ActiveXObject(("ShockwaveFlash.ShockwaveFlash." + version));
+ flashIsInstalled = true;
+ }
+ catch(e){
+ // Throws an error if the version isn't available
+ }
+ }
+ else if(navigator.plugins && navigator.mimeTypes.length > 0){
+ flash = navigator.plugins["Shockwave Flash"];
+ if(flash){
+ var flashVersion = navigator.plugins["Shockwave Flash"].description.replace(/.*\s(\d+\.\d+).*/, "$1");
+ if(flashVersion >= version){
+ flashIsInstalled = true;
+ }
+ }
+ }
+ return flashIsInstalled;
+ },
+ _validString: function(url) {
+ return (url && typeof url === "string"); // Empty strings return false
+ },
+ _limitValue: function(value, min, max) {
+ return (value < min) ? min : ((value > max) ? max : value);
+ },
+ _urlNotSetError: function(context) {
+ this._error( {
+ type: $.jPlayer.error.URL_NOT_SET,
+ context: context,
+ message: $.jPlayer.errorMsg.URL_NOT_SET,
+ hint: $.jPlayer.errorHint.URL_NOT_SET
+ });
+ },
+ _flashError: function(error) {
+ var errorType;
+ if(!this.internal.ready) {
+ errorType = "FLASH";
+ } else {
+ errorType = "FLASH_DISABLED";
+ }
+ this._error( {
+ type: $.jPlayer.error[errorType],
+ context: this.internal.flash.swf,
+ message: $.jPlayer.errorMsg[errorType] + error.message,
+ hint: $.jPlayer.errorHint[errorType]
+ });
+ // Allow the audio player to recover if display:none and then shown again, or with position:fixed on Firefox.
+ // This really only affects audio in a media player, as an audio player could easily move the jPlayer element away from such issues.
+ this.internal.flash.jq.css({'width':'1px', 'height':'1px'});
+ },
+ _error: function(error) {
+ this._trigger($.jPlayer.event.error, error);
+ if(this.options.errorAlerts) {
+ this._alert("Error!" + (error.message ? "\n\n" + error.message : "") + (error.hint ? "\n\n" + error.hint : "") + "\n\nContext: " + error.context);
+ }
+ },
+ _warning: function(warning) {
+ this._trigger($.jPlayer.event.warning, undefined, warning);
+ if(this.options.warningAlerts) {
+ this._alert("Warning!" + (warning.message ? "\n\n" + warning.message : "") + (warning.hint ? "\n\n" + warning.hint : "") + "\n\nContext: " + warning.context);
+ }
+ },
+ _alert: function(message) {
+ alert("jPlayer " + this.version.script + " : id='" + this.internal.self.id +"' : " + message);
+ },
+ _emulateHtmlBridge: function() {
+ var self = this,
+ methods = $.jPlayer.emulateMethods;
+
+ // Emulate methods on jPlayer's DOM element.
+ $.each( $.jPlayer.emulateMethods.split(/\s+/g), function(i, name) {
+ self.internal.domNode[name] = function(arg) {
+ self[name](arg);
+ };
+
+ });
+
+ // Bubble jPlayer events to its DOM element.
+ $.each($.jPlayer.event, function(eventName,eventType) {
+ var nativeEvent = true;
+ $.each( $.jPlayer.reservedEvent.split(/\s+/g), function(i, name) {
+ if(name === eventName) {
+ nativeEvent = false;
+ return false;
+ }
+ });
+ if(nativeEvent) {
+ self.element.bind(eventType + ".jPlayer.jPlayerHtml", function() { // With .jPlayer & .jPlayerHtml namespaces.
+ self._emulateHtmlUpdate();
+ var domEvent = document.createEvent("Event");
+ domEvent.initEvent(eventName, false, true);
+ self.internal.domNode.dispatchEvent(domEvent);
+ });
+ }
+ // The error event would require a special case
+ });
+
+ // IE9 has a readyState property on all elements. The document should have it, but all (except media) elements inherit it in IE9. This conflicts with Popcorn, which polls the readyState.
+ },
+ _emulateHtmlUpdate: function() {
+ var self = this;
+
+ $.each( $.jPlayer.emulateStatus.split(/\s+/g), function(i, name) {
+ self.internal.domNode[name] = self.status[name];
+ });
+ $.each( $.jPlayer.emulateOptions.split(/\s+/g), function(i, name) {
+ self.internal.domNode[name] = self.options[name];
+ });
+ },
+ _destroyHtmlBridge: function() {
+ var self = this;
+
+ // Bridge event handlers are also removed by destroy() through .jPlayer namespace.
+ this.element.unbind(".jPlayerHtml"); // Remove all event handlers created by the jPlayer bridge. So you can change the emulateHtml option.
+
+ // Remove the methods and properties
+ var emulated = $.jPlayer.emulateMethods + " " + $.jPlayer.emulateStatus + " " + $.jPlayer.emulateOptions;
+ $.each( emulated.split(/\s+/g), function(i, name) {
+ delete self.internal.domNode[name];
+ });
+ }
+ };
+
+ $.jPlayer.error = {
+ FLASH: "e_flash",
+ FLASH_DISABLED: "e_flash_disabled",
+ NO_SOLUTION: "e_no_solution",
+ NO_SUPPORT: "e_no_support",
+ URL: "e_url",
+ URL_NOT_SET: "e_url_not_set",
+ VERSION: "e_version"
+ };
+
+ $.jPlayer.errorMsg = {
+ FLASH: "jPlayer's Flash fallback is not configured correctly, or a command was issued before the jPlayer Ready event. Details: ", // Used in: _flashError()
+ FLASH_DISABLED: "jPlayer's Flash fallback has been disabled by the browser due to the CSS rules you have used. Details: ", // Used in: _flashError()
+ NO_SOLUTION: "No solution can be found by jPlayer in this browser. Neither HTML nor Flash can be used.", // Used in: _init()
+ NO_SUPPORT: "It is not possible to play any media format provided in setMedia() on this browser using your current options.", // Used in: setMedia()
+ URL: "Media URL could not be loaded.", // Used in: jPlayerFlashEvent() and _addHtmlEventListeners()
+ URL_NOT_SET: "Attempt to issue media playback commands, while no media url is set.", // Used in: load(), play(), pause(), stop() and playHead()
+ VERSION: "jPlayer " + $.jPlayer.prototype.version.script + " needs Jplayer.swf version " + $.jPlayer.prototype.version.needFlash + " but found " // Used in: jPlayerReady()
+ };
+
+ $.jPlayer.errorHint = {
+ FLASH: "Check your swfPath option and that Jplayer.swf is there.",
+ FLASH_DISABLED: "Check that you have not display:none; the jPlayer entity or any ancestor.",
+ NO_SOLUTION: "Review the jPlayer options: support and supplied.",
+ NO_SUPPORT: "Video or audio formats defined in the supplied option are missing.",
+ URL: "Check media URL is valid.",
+ URL_NOT_SET: "Use setMedia() to set the media URL.",
+ VERSION: "Update jPlayer files."
+ };
+
+ $.jPlayer.warning = {
+ CSS_SELECTOR_COUNT: "e_css_selector_count",
+ CSS_SELECTOR_METHOD: "e_css_selector_method",
+ CSS_SELECTOR_STRING: "e_css_selector_string",
+ OPTION_KEY: "e_option_key"
+ };
+
+ $.jPlayer.warningMsg = {
+ CSS_SELECTOR_COUNT: "The number of css selectors found did not equal one: ",
+ CSS_SELECTOR_METHOD: "The methodName given in jPlayer('cssSelector') is not a valid jPlayer method.",
+ CSS_SELECTOR_STRING: "The methodCssSelector given in jPlayer('cssSelector') is not a String or is empty.",
+ OPTION_KEY: "The option requested in jPlayer('option') is undefined."
+ };
+
+ $.jPlayer.warningHint = {
+ CSS_SELECTOR_COUNT: "Check your css selector and the ancestor.",
+ CSS_SELECTOR_METHOD: "Check your method name.",
+ CSS_SELECTOR_STRING: "Check your css selector is a string.",
+ OPTION_KEY: "Check your option name."
+ };
+})(jQuery);
diff --git a/apps/media/js/player.js b/apps/media/js/player.js
index 3c022e9f8c4..1f76356fd97 100644
--- a/apps/media/js/player.js
+++ b/apps/media/js/player.js
@@ -93,9 +93,11 @@ var PlayList={
ended:PlayList.next,
pause:function(){
localStorage.setItem(oc_current_user+'oc_playlist_playing','false');
+ document.title = "ownCloud";
},
- play:function(){
+ play:function(event){
localStorage.setItem(oc_current_user+'oc_playlist_playing','true');
+ document.title = "\u25b8 " + event.jPlayer.status.media.name + " - " + event.jPlayer.status.media.artist + " - ownCloud";
},
supplied:type,
ready:function(){
diff --git a/apps/media/js/playlist.js b/apps/media/js/playlist.js
index 57180b3be7b..089065989ae 100644
--- a/apps/media/js/playlist.js
+++ b/apps/media/js/playlist.js
@@ -1,11 +1,23 @@
PlayList.render=function(){
$('#playlist').show();
+
+ /*
+ * We should not empty() PlayList.parent() but thorougly manage its
+ * elements instead because some code might be attached to those.
+ * JQuery tipsies are one of them. The following line make sure they
+ * are all removed before we delete the associated <li/>.
+ */
+ $(".tipsy").remove();
+
PlayList.parent.empty();
for(var i=0;i<PlayList.items.length;i++){
var item=PlayList.items[i];
var li=$('<li/>');
- li.append(item.name);
- li.attr('class', 'jp-playlist-' + i);
+ li.attr('class', 'jp-playlist-' + i);
+ li.attr('title', item.artist + ' - ' + item.name + '<br/>(' + item.album + ')');
+ var div = $('<div class="label">' + item.name + '</div>');
+ li.append(div);
+ $('.jp-playlist-' + i).tipsy({gravity:'w', fade:true, live:true, html:true});
var img=$('<img class="remove svg action" src="'+OC.imagePath('core','actions/delete')+'"/>');
img.click(function(event){
event.stopPropagation();
diff --git a/apps/media/lib_collection.php b/apps/media/lib_collection.php
index caa3ac3f479..1240f1de2f0 100644
--- a/apps/media/lib_collection.php
+++ b/apps/media/lib_collection.php
@@ -127,7 +127,7 @@ class OC_MEDIA_COLLECTION{
$search='%';
}
$query=OC_DB::prepare("SELECT DISTINCT *PREFIX*media_artists.artist_name AS artist_name , *PREFIX*media_artists.artist_id AS artist_id FROM *PREFIX*media_artists
- INNER JOIN *PREFIX*media_songs ON *PREFIX*media_artists.artist_id=*PREFIX*media_songs.song_artist WHERE artist_name LIKE ? AND *PREFIX*media_songs.song_user=?");
+ INNER JOIN *PREFIX*media_songs ON *PREFIX*media_artists.artist_id=*PREFIX*media_songs.song_artist WHERE artist_name LIKE ? AND *PREFIX*media_songs.song_user=? ORDER BY artist_name");
return $query->execute(array($search,self::$uid))->fetchAll();
}
@@ -160,7 +160,7 @@ class OC_MEDIA_COLLECTION{
*/
static public function getAlbums($artist=0,$search='%',$exact=false){
$cmd="SELECT DISTINCT *PREFIX*media_albums.album_name AS album_name , *PREFIX*media_albums.album_artist AS album_artist , *PREFIX*media_albums.album_id AS album_id
- FROM *PREFIX*media_albums INNER JOIN *PREFIX*media_songs ON *PREFIX*media_albums.album_id=*PREFIX*media_songs.song_album WHERE *PREFIX*media_songs.song_user=? ";
+ FROM *PREFIX*media_albums INNER JOIN *PREFIX*media_songs ON *PREFIX*media_albums.album_id=*PREFIX*media_songs.song_album WHERE *PREFIX*media_songs.song_user=? ORDER BY album_name";
$params=array(self::$uid);
if($artist!=0){
$cmd.="AND *PREFIX*media_albums.album_artist = ? ";
@@ -233,7 +233,7 @@ class OC_MEDIA_COLLECTION{
}else{
$searchString='';
}
- $query=OC_DB::prepare("SELECT * FROM *PREFIX*media_songs WHERE song_user=? $artistString $albumString $searchString");
+ $query=OC_DB::prepare("SELECT * FROM *PREFIX*media_songs WHERE song_user=? $artistString $albumString $searchString ORDER BY song_track, song_name");
return $query->execute($params)->fetchAll();
}
@@ -378,4 +378,4 @@ class OC_MEDIA_COLLECTION{
}
}
-?> \ No newline at end of file
+?>
diff --git a/apps/media/lib_scanner.php b/apps/media/lib_scanner.php
index c2bea2d836d..4039cce09ee 100644
--- a/apps/media/lib_scanner.php
+++ b/apps/media/lib_scanner.php
@@ -30,7 +30,6 @@ class OC_MEDIA_SCANNER{
//these are used to store which artists and albums we found, it can save a lot of addArtist/addAlbum calls
static private $artists=array();
static private $albums=array();//stored as "$artist/$album" to allow albums with the same name from different artists
- static private $useMp3Info=null;
/**
* scan a folder for music
@@ -70,59 +69,55 @@ class OC_MEDIA_SCANNER{
* @return boolean
*/
public static function scanFile($path){
- if(is_null(self::$useMp3Info)){
- self::$useMp3Info=OC_Helper::canExecute("mp3info");
- }
$file=OC_Filesystem::getLocalFile($path);
- if(substr($path,-3)=='mp3' and self::$useMp3Info){//use the command line tool id3info if possible
- $output=array();
- $size=filesize($file);
- exec('mp3info -p "%a\n%l\n%t\n%n\n%S" "'.$file.'"',$output);
- if(count($output)>4){
- $artist=$output[0];
- $album=$output[1];
- $title=$output[2];
- $track=$output[3];
- $length=$output[4];
- }else{
- return; //invalid mp3 file
- }
+ if(!self::isMusic($path)){
+ return;
+ }
+ if(!self::$getID3){
+ self::$getID3=@new getID3();
+ self::$getID3->encoding='UTF-8';
+ }
+ $data=@self::$getID3->analyze($file);
+ getid3_lib::CopyTagsToComments($data);
+ if(!isset($data['comments'])){
+ OC_Log::write('media',"error reading id3 tags in '$file'",OC_Log::WARN);
+ return;
+ }
+ if(!isset($data['comments']['artist'])){
+ OC_Log::write('media',"error reading artist tag in '$file'",OC_Log::WARN);
+ $artist='unknown';
}else{
- if(!self::isMusic($path)){
- return;
- }
- if(!self::$getID3){
- self::$getID3=@new getID3();
- self::$getID3->encoding='UTF-8';
- }
- $data=@self::$getID3->analyze($file);
- getid3_lib::CopyTagsToComments($data);
- if(!isset($data['comments'])){
- OC_Log::write('media',"error reading id3 tags in '$file'",OC_Log::WARN);
- return;
- }
- if(!isset($data['comments']['artist'])){
- OC_Log::write('media',"error reading artist tag in '$file'",OC_Log::WARN);
- $artist='unknown';
- }else{
- $artist=stripslashes($data['comments']['artist'][0]);
- }
- if(!isset($data['comments']['album'])){
- OC_Log::write('media',"error reading album tag in '$file'",OC_Log::WARN);
- $album='unknown';
- }else{
- $album=stripslashes($data['comments']['album'][0]);
- }
- if(!isset($data['comments']['title'])){
- OC_Log::write('media',"error reading title tag in '$file'",OC_Log::WARN);
- $title='unknown';
- }else{
- $title=stripslashes($data['comments']['title'][0]);
- }
- $size=$data['filesize'];
- $track=(isset($data['comments']['track']))?$data['comments']['track'][0]:0;
- $length=isset($data['playtime_seconds'])?round($data['playtime_seconds']):0;
+ $artist=stripslashes($data['comments']['artist'][0]);
+ }
+ if(!isset($data['comments']['album'])){
+ OC_Log::write('media',"error reading album tag in '$file'",OC_Log::WARN);
+ $album='unknown';
+ }else{
+ $album=stripslashes($data['comments']['album'][0]);
+ }
+ if(!isset($data['comments']['title'])){
+ OC_Log::write('media',"error reading title tag in '$file'",OC_Log::WARN);
+ $title='unknown';
+ }else{
+ $title=stripslashes($data['comments']['title'][0]);
}
+ $size=$data['filesize'];
+ if (isset($data['comments']['track']))
+ {
+ $track = $data['comments']['track'][0];
+ }
+ else if (isset($data['comments']['track_number']))
+ {
+ $track = $data['comments']['track_number'][0];
+ $track = explode('/',$track);
+ $track = $track[0];
+ }
+ else
+ {
+ $track = 0;
+ }
+ $length=isset($data['playtime_seconds'])?round($data['playtime_seconds']):0;
+
if(!isset(self::$artists[$artist])){
$artistId=OC_MEDIA_COLLECTION::addArtist($artist);
self::$artists[$artist]=$artistId;
diff --git a/apps/user_webfinger/appinfo/install.php b/apps/user_webfinger/appinfo/install.php
index 079043cd102..f570a3a249b 100644
--- a/apps/user_webfinger/appinfo/install.php
+++ b/apps/user_webfinger/appinfo/install.php
@@ -3,4 +3,4 @@ $appInfoDir = __DIR__;
$thisAppDir = dirname($appInfoDir);
$appsDir = dirname($thisAppDir);
$ownCloudDir = dirname($appsDir);
-symlink($thisAppDir, $ownCloudDir.'/.well-known');
+@symlink($thisAppDir, $ownCloudDir.'/.well-known');