From 23f68d821ec1f5de2d446013dc3fad325333476e Mon Sep 17 00:00:00 2001 From: Thomas Marstrander Date: Wed, 4 Mar 2015 10:06:35 +0100 Subject: [PATCH 1/5] Added woff to css inline --- fonts/h5p.woff | Bin 4324 -> 0 bytes styles/h5p.css | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) delete mode 100644 fonts/h5p.woff diff --git a/fonts/h5p.woff b/fonts/h5p.woff deleted file mode 100644 index 66394c10c29d618c76bc5a15fffdc7f78a306179..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 4324 zcmeHKdyHIF89(27&b{-zyEAil+wRWp%)1B3)oP=Y~BFd-7aD3O>bMBJ&rbMNf3TOcO> z?alqp`QG0--?`_U?|$K;$w@{GPwI6R4f^9DZSm#LMVAg%7^4WdpR(Yxkk+!F!sq*gF>9-MwwHaox-f96b}Z>c*2iq8CL zh4gP}*#*L&Ax6+mE{TO0Bj*O8KZyU|c=POCA^2T(?o={9mFSt9rk|ya)AZ0yJAO$U zcQB&+*|Xwaewr1alTYwWx|{p8LcTag^-7MidJSbpMQymu3;gKt)muv4^{s0!cci*q zCG}U8bS_`JwVoT;a&?WLMmt=-bkjQLc~?Jb%%j?U-dVTl(lX2jFe^dF*^}ZZe**dG zwBNu&ylQ2X2N6s)Q>e8UYSkJbQ_b-Etf_TdyUO-g)dr@gzx;Tma{B;(!jcPY+ppiW zsrl9FgVh(Sh{fp+_EYfy|26AoYZ&V@j?~q_b5&TOXw1Vv%!~xdI{js zJA%vo3aL=xD3J#-L9Yl!QPOh1RP31_j7@wGhe`)6qeu3Ax-Ytqj7e{tO`(f6D76qkG@`-({LGmE)oK{kS~FMB?f zGHJAx`bHA=iwd?#aSi#kVYGSOMIvIP+9%_3pOWUy2cxEH+>=XLCta|jyb)1fQ+Okh z$BgTm$C{6w#jq#lYsBOvKgB3*-RUYp}MD^n(J z?wRbXwRs+;QZuH*E0jE6X{}B352;SGt9lf;S+8c;z4%RwLk75o|-t8%|Cec)#o;*=`-F4ili zNl@kbDoJYVZ*MQQxd|mAk>2r~n~92u$c^PlitLcj1vMjy6;YQW$qXuuC{D9zN=Rvd zSiHye2hxd-m^LI7zJYi#3fK3oiuXl?SMac^*t=Mis2|0vQ;}#=VH`aZIWCDOFs7ah zdT_bMvz+&D?Z<|fh%Yo>SzF>!YHF8#(;UFZI25(@gi54H-buT_=?)fNYcSPL~k1g6W4wh zwns-79CT(J8eEGTP$Qi$IX{NJf-~eO=juH44STQBA@-d3A%7&e zS2wT=?YFvkffjl{xIq0phK@b0l_-C6)|era zHoIrh3>h=qqGxxvXgWP>GG;K83<8D5avE`wOTgg!Cm#81a>GAZRN7s|ej9t}wxvC) z2Ky&v|E|IZHo-p{Q>!gQw*GuuQropH!2>gRo>!~se!y|S9e@Eqms-tN!pm#G^8hQi z{5ilOz{`Oj7ymHbY=~XYzRCVbxAFnLm;YTJmcLhDR4?fb8h^FHT-qqc+`wXCq)Ug9 zV2`){@QCS_12OR4zDU z9{LRN&}WE;K0{o?w!dW?`fRWo+s`h;pUaJGj(wi(V|!T-ThGeKLLh6@_J;_&1WLQu wO>8%tfpTa#85kUZ$u3Cu25x590rb~`cMUs)_CmH3T2lb)yd2KowjcZa2h12PrvLx| diff --git a/styles/h5p.css b/styles/h5p.css index dfb92db..141be24 100644 --- a/styles/h5p.css +++ b/styles/h5p.css @@ -5,7 +5,7 @@ font-family: 'h5p'; src:url('../fonts/h5p.eot?-9qymee'); src:url('../fonts/h5p.eot?#iefix-9qymee') format('embedded-opentype'), - url('../fonts/h5p.woff?-9qymee') format('woff'), + url('data:application/font-woff;base64,d09GRgABAAAAABDkAAsAAAAAEJgAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAABPUy8yAAABCAAAAGAAAABgDxIFvmNtYXAAAAFoAAAAVAAAAFToz+aCZ2FzcAAAAbwAAAAIAAAACAAAABBnbHlmAAABxAAADPAAAAzw92xLRmhlYWQAAA60AAAANgAAADYFfYcCaGhlYQAADuwAAAAkAAAAJA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oNXAAaAA1AHAAUgBlAGcAdQBsAGEAcgBoADUAcABGAG8AbgB0ACAAZwBlAG4AZQByAGEAdABlAGQAIABiAHkAIABJAGMAbwBNAG8AbwBuAC4AAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==') format('woff'), url('../fonts/h5p.ttf?-9qymee') format('truetype'), url('../fonts/h5p.svg?-9qymee#h5p') format('svg'); font-weight: normal; From 7ef9ffbf1f470082e15f276606750b57da46753b Mon Sep 17 00:00:00 2001 From: Frode Petterson Date: Wed, 11 Mar 2015 11:40:07 +0100 Subject: [PATCH 2/5] Added default sort option to data view. Improved buttons. --- js/h5p-data-view.js | 17 +++++++++-------- js/h5p-utils.js | 27 ++++++++++++++++++++++++--- 2 files changed, 33 insertions(+), 11 deletions(-) diff --git a/js/h5p-data-view.js b/js/h5p-data-view.js index 323290a..d856933 100644 --- a/js/h5p-data-view.js +++ b/js/h5p-data-view.js @@ -32,8 +32,9 @@ var H5PDataView = (function ($) { * search in column 2. * @param {Function} loaded * Callback for when data has been loaded. + * @param {Object} order */ - function H5PDataView(container, source, headers, l10n, classes, filters, loaded) { + function H5PDataView(container, source, headers, l10n, classes, filters, loaded, order) { var self = this; self.$container = $(container).addClass('h5p-data-view').html(''); @@ -44,6 +45,7 @@ var H5PDataView = (function ($) { self.classes = (classes === undefined ? {} : classes); self.filters = (filters === undefined ? [] : filters); self.loaded = loaded; + self.order = order; self.limit = 20; self.offset = 0; @@ -68,8 +70,8 @@ var H5PDataView = (function ($) { url += (url.indexOf('?') === -1 ? '?' : '&') + 'offset=' + self.offset + '&limit=' + self.limit; // Add sorting - if (self.sortBy !== undefined && self.sortDir !== undefined) { - url += '&sortBy=' + self.sortBy + '&sortDir=' + self.sortDir; + if (self.order !== undefined) { + url += '&sortBy=' + self.order.by + '&sortDir=' + self.order.dir; } // Add filters @@ -144,12 +146,11 @@ var H5PDataView = (function ($) { // Create new table self.table = new H5PUtils.Table(self.classes, self.headers); - self.table.setHeaders(self.headers, function (col, dir) { - // Sorting column or direction has changed callback. - self.sortBy = col; - self.sortDir = dir; + self.table.setHeaders(self.headers, function (order) { + // Sorting column or direction has changed. + self.order = order; self.loadData(); - }); + }, self.order); self.table.appendTo(self.$container); } diff --git a/js/h5p-utils.js b/js/h5p-utils.js index d90ca58..423eb30 100644 --- a/js/h5p-utils.js +++ b/js/h5p-utils.js @@ -182,18 +182,30 @@ var H5PUtils = H5PUtils || {}; if (sortByCol !== undefined && col.sortable === true) { // Make sortable options.role = 'button'; - options.tabIndex = 1; + options.tabIndex = 0; // This is the first sortable column, use as default sort if (sortCol === undefined) { sortCol = id; sortDir = 0; + } + + // This is the sort column + if (sortCol === id) { options['class'] = 'h5p-sort'; + if (sortDir === 1) { + options['class'] += ' h5p-reverse'; + } } options.on.click = function () { sort($th, id); }; + options.on.keypress = function (event) { + if ((event.charCode || event.keyCode) === 32) { // Space + sort($th, id); + } + }; } } @@ -232,7 +244,10 @@ var H5PUtils = H5PUtils || {}; sortDir = 0; } - sortByCol(sortCol, sortDir); + sortByCol({ + by: sortCol, + dir: sortDir + }); }; /** @@ -244,11 +259,17 @@ var H5PUtils = H5PUtils || {}; * "text" and "sortable". E.g. * [{text: 'Col 1', sortable: true}, 'Col 2', 'Col 3'] * @param {Function} sort Callback which is runned when sorting changes + * @param {Object} [order] */ - this.setHeaders = function (cols, sort) { + this.setHeaders = function (cols, sort, order) { numCols = cols.length; sortByCol = sort; + if (order) { + sortCol = order.by; + sortDir = order.dir; + } + // Create new head var $newThead = $(''); var $tr = $('').appendTo($newThead); From fb823285357bfd0f616d02f4d10766feb40208a0 Mon Sep 17 00:00:00 2001 From: Frode Petterson Date: Fri, 13 Mar 2015 12:51:31 +0100 Subject: [PATCH 3/5] Fullscreen fix --- js/h5p.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/js/h5p.js b/js/h5p.js index 4223230..a9c2617 100644 --- a/js/h5p.js +++ b/js/h5p.js @@ -33,8 +33,6 @@ else if (document.documentElement.msRequestFullscreen) { // Keep track of when the H5Ps where started H5P.opened = {}; -H5P.canHasFullScreen = (H5P.isFramed && H5P.externalEmbed !== false) ? (document.fullscreenEnabled || document.webkitFullscreenEnabled || document.mozFullScreenEnabled || document.msFullscreenEnabled) : true; - /** * Initialize H5P content. * Scans for ".h5p-content" in the document and initializes H5P instances where found. @@ -45,6 +43,11 @@ H5P.init = function (target) { H5P.$body = H5P.jQuery(document.body); } + // Determine if we can use full screen + if (H5P.canHasFullScreen === undefined) { + H5P.canHasFullScreen = (H5P.isFramed && H5P.externalEmbed !== false) ? (document.fullscreenEnabled || document.webkitFullscreenEnabled || document.mozFullScreenEnabled || document.msFullscreenEnabled) : true; + } + // H5Ps added in normal DIV. var $containers = H5P.jQuery('.h5p-content:not(.h5p-initialized)', target).each(function () { var $element = H5P.jQuery(this).addClass('h5p-initialized'); From 51a1d333e2129ad314556ed52c9742d91ebb05e4 Mon Sep 17 00:00:00 2001 From: Frode Petterson Date: Thu, 19 Mar 2015 16:58:48 +0100 Subject: [PATCH 4/5] Improved packaging. Made sure zip format is followed by always using forward slashes. This will make h5p export work on Windows. --- h5p.classes.php | 51 ++++++++++++++++++++++++++++++++++++------------- 1 file changed, 38 insertions(+), 13 deletions(-) diff --git a/h5p.classes.php b/h5p.classes.php index 47df2f2..5a1884a 100644 --- a/h5p.classes.php +++ b/h5p.classes.php @@ -14,7 +14,7 @@ interface H5PFrameworkInterface { * - h5pVersion: The version of the H5P plugin/module */ public function getPlatformInfo(); - + /** * Fetches a file from a remote server using HTTP GET @@ -1519,28 +1519,53 @@ Class H5PExport { $results = print_r(json_encode($h5pJson), true); file_put_contents($tempPath . DIRECTORY_SEPARATOR . 'h5p.json', $results); + // Get a complete file list from our tmp dir + $files = array(); + self::populateFileList($tempPath, $files); + // Create new zip instance. $zip = new ZipArchive(); $zip->open($zipPath, ZIPARCHIVE::CREATE | ZIPARCHIVE::OVERWRITE); - // Get all files and folders in $tempPath - $iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($tempPath . DIRECTORY_SEPARATOR)); - // Add files to zip - foreach ($iterator as $key => $value) { - $test = '.'; - // Do not add the folders '.' and '..' to the zip. This will make zip invalid. - if (substr_compare($key, $test, -strlen($test), strlen($test)) !== 0) { - // Get files path in $tempPath - $filePath = explode($tempPath . DIRECTORY_SEPARATOR, $key); - // Add files to the zip with the intended file-structure - $zip->addFile($key, $filePath[1]); - } + // Add all the files from the tmp dir. + foreach ($files as $file) { + // Please note that the zip format has no concept of folders, we must + // use forward slashes to separate our directories. + $zip->addFile($file->absolutePath, $file->relativePath); } + // Close zip and remove temp dir $zip->close(); H5PCore::deleteFileTree($tempPath); } + /** + * Recursive function the will add the files of the given directory to the + * given files list. All files are objects with an absolute path and + * a relative path. The relative path is forward slashes only! Great for + * use in zip files and URLs. + * + * @param string $dir path + * @param array $files list + * @param string $relative prefix. Optional + */ + private static function populateFileList($dir, &$files, $relative = '') { + $strip = strlen($dir) + 1; + foreach (glob($dir . DIRECTORY_SEPARATOR . '*') as $file) { + $rel = $relative . substr($file, $strip); + if (is_dir($file)) { + self::populateFileList($file, $files, $rel . '/'); + } + else { + // TODO: Should we filter out files that aren't in the whitelist? + $files[] = (object) array( + 'absolutePath' => $file, + 'relativePath' => $rel + ); + } + } + } + /** * Delete .h5p file * From 8494e85c3e572e366d4c650c7a3b882e9eb22e5f Mon Sep 17 00:00:00 2001 From: Svein-Tore Griff With Date: Thu, 19 Mar 2015 19:27:44 +0100 Subject: [PATCH 5/5] Remove todo items --- h5p.classes.php | 8 -------- 1 file changed, 8 deletions(-) diff --git a/h5p.classes.php b/h5p.classes.php index 5a1884a..b6df5af 100644 --- a/h5p.classes.php +++ b/h5p.classes.php @@ -1487,8 +1487,6 @@ Class H5PExport { // Build h5p.json $h5pJson = array ( 'title' => $content['title'], - // TODO - stop using 'und', this is not the preferred way. - // Either remove language from the json if not existing, or use "language": null 'language' => (isset($content['language']) && strlen(trim($content['language'])) !== 0) ? $content['language'] : 'und', 'mainLibrary' => $content['library']['name'], 'embedTypes' => $embedTypes, @@ -1557,7 +1555,6 @@ Class H5PExport { self::populateFileList($file, $files, $rel . '/'); } else { - // TODO: Should we filter out files that aren't in the whitelist? $files[] = (object) array( 'absolutePath' => $file, 'relativePath' => $rel @@ -1742,8 +1739,6 @@ class H5PCore { // Recreate export file $exporter = new H5PExport($this->h5pF, $this); $exporter->createExportFile($content); - - // TODO: Should we rather create the file once first accessed, like imagecache? } // Cache. @@ -2248,8 +2243,6 @@ class H5PCore { /** * Helper function for creating markup for the unsupported libraries list * - * TODO: Make help text translatable - * * @return string Html * */ public function createMarkupForUnsupportedLibraryList($libraries) { @@ -2350,7 +2343,6 @@ class H5PContentValidator { // Keep track of the libraries we load to avoid loading it multiple times. $this->libraries = array(); - // TODO: Should this possible be done in core's loadLibrary? This might be done multiple places. // Keep track of all dependencies for the given content. $this->dependencies = array();