From 1029c781c9bad45d8442f0e43470f7f56b65ec4f Mon Sep 17 00:00:00 2001 From: nael Date: Mon, 7 Jan 2019 14:15:45 +0100 Subject: [PATCH] wait #2468 @1 --- .../ONGLETS-SRC/10doigts/init.js | 1 + .../ONGLETS-SRC/10doigts/multimedia.css | 0 .../ONGLETS-SRC/10doigts/multimedia.js | 283 +++++++++ .../ONGLETS-SRC/10doigts/tabs.svg | 581 ++++++++++++++++++ 4 files changed, 865 insertions(+) create mode 100644 Fluidbook-10doigts-Onglets/ONGLETS-SRC/10doigts/init.js create mode 100644 Fluidbook-10doigts-Onglets/ONGLETS-SRC/10doigts/multimedia.css create mode 100644 Fluidbook-10doigts-Onglets/ONGLETS-SRC/10doigts/multimedia.js create mode 100644 Fluidbook-10doigts-Onglets/ONGLETS-SRC/10doigts/tabs.svg diff --git a/Fluidbook-10doigts-Onglets/ONGLETS-SRC/10doigts/init.js b/Fluidbook-10doigts-Onglets/ONGLETS-SRC/10doigts/init.js new file mode 100644 index 0000000..24ad355 --- /dev/null +++ b/Fluidbook-10doigts-Onglets/ONGLETS-SRC/10doigts/init.js @@ -0,0 +1 @@ +$($id).tabs($init); \ No newline at end of file diff --git a/Fluidbook-10doigts-Onglets/ONGLETS-SRC/10doigts/multimedia.css b/Fluidbook-10doigts-Onglets/ONGLETS-SRC/10doigts/multimedia.css new file mode 100644 index 0000000..e69de29 diff --git a/Fluidbook-10doigts-Onglets/ONGLETS-SRC/10doigts/multimedia.js b/Fluidbook-10doigts-Onglets/ONGLETS-SRC/10doigts/multimedia.js new file mode 100644 index 0000000..2bea0ec --- /dev/null +++ b/Fluidbook-10doigts-Onglets/ONGLETS-SRC/10doigts/multimedia.js @@ -0,0 +1,283 @@ +(function ($) { + function JQtabs(element, data) { + this.element = element; + this.cont; + this.data = data; + this.visibility = {}; + + this.naturalDimensions = {width: 0, height: 0}; + + /* Change contents from here */ + + this.hideOnLastPage = false; + this.hideOnFirstPage = true; + this.hideOnPortrait = false; + + this.image = 'tabs.svg'; + + var pages = [6, 102, 111, 142, 150, 168, 184, 205, 213, 240, 246, 272, 311, 350, 378, 386, 402, 418, 424, 427, 432, 449, 453, 468, 488, 497]; + + this.links = []; + var $this = this; + $.each(pages, function (index, value) { + if (value % 2 == 1) { + value--; + } + $this.links.push({ + css: {height: (100 / pages.length) + '%', top: (100 / pages.length * index) + '%'}, + page: value, + id: 'o' + (index + 1) + }); + }); + + /* available modes & alignments : + side|right: tabs are stuck at the right of the publication + side|left: ______________________ left + top|center: tabs are placed on top of the publication centered horizontaly + + top|left:_____________________________________________________ at left + top|right:____________________________________________________ at right + */ + this.mode = 'side'; + this.align = 'left'; + + this.margin = -15; // Space between tabs and book + + this.hideEdge = 'left'; // Possible values : left, right, both, none + this.hideWhenOverlapingArrows = true; + + /* Stop changing contents here or do it AYOR */ + + this.hideOnZoom = true; // true is recommanded + + this.init(); + } + + JQtabs.prototype = { + init: function () { + var $this = this; + this.element.append('
'); + this.cont = this.element.find('.tabs'); + + $.get(this.data.path + this.image, {}, function (data) { + $this.cont.append(data); + $this.naturalDimensions.width = Math.floor(parseFloat($(data).attr('width'))); + $this.naturalDimensions.height = Math.floor(parseFloat($(data).attr('height'))); + $this.svg = $this.cont.find('svg'); + $this.svg.addClass('tabsimg').css({height: '100%', width: 'auto'}); + }, 'text'); + + this.createLinks(); + this.initStandardEvents(); + }, + + changePage: function (page) { + var id = 'oo'; + var $this = this; + $.each(this.links, function (k, v) { + if (page >= v.page) { + try { + if (v.last != undefined && page >= v.last) { + id = 'none'; + } else { + id = v.id; + } + } catch (e) { + + } + + } + }); + + if (id == 'none') { + this.svg.find('.active').removeClass('active'); + } else { + try { + this.svg.find('.active:not(#' + id + ')').removeClass('active'); + this.svg.find('#' + id).addClass('active'); + } catch (err) { + + } + } + }, + + hideEdges: function (hide) { + if (!hide) { + $("#edges .edge").css('visibility', 'visible'); + return; + } + if (this.hideEdge == undefined || this.hideEdge == 'none') { + return; + } + + if (this.hideEdge == 'left' || this.hideEdge == 'both') { + $("#edges .edge.left").css({visibility: 'hidden'}); + } + if (this.hideEdge == 'right' || this.hideEdge == 'both') { + $("#edges .edge.right").css({visibility: 'hidden'}); + } + }, + + createLinks: function () { + var $this = this; + $(this.links).each(function (k, v) { + var l = $(''); + $this.cont.append(l); + l.css(v.css); + if (v.page) { + l.attr('href', '#/page/' + v.page); + } + }); + }, + + initStandardEvents: function () { + var $this = this; + + $(fluidbook).on('fluidbook.resize', function (e, data) { + $this.resize(data); + return true; + }); + + if (this.hideOnZoom) { + this.visibility.zoomin = true; + $(fluidbook).on('fluidbook.zoom.in.start', function (e) { + $this.changeVisibility('zoomin', false); + }); + $(fluidbook).on('fluidbook.zoom.out.end', function (e) { + $this.changeVisibility('zoomin', true); + }); + } + + if (this.hideOnPortrait) { + this.visibility.portrait = true; + $(fluidbook).on('fluidbook.resize.orientation', function (e, data) { + if (data.orientation == 'portrait') { + $this.changeVisibility('portrait', false); + } else { + $this.changeVisibility('portrait', true); + } + }); + } + + if (this.hideOnLastPage || this.hideOnFirstPage) { + if (this.hideOnLastPage) { + this.visibility.lastpage = true; + } + if (this.hideOnFirstPage) { + this.visibility.firstpage = true; + } + + $(fluidbook).on('fluidbook.page.change.start', function (e, page) { + if ($this.hideOnFirstPage) { + if (page <= 1) { + $this.changeVisibility('firstpage', false); + } + } + if ($this.hideOnLastPage) { + var last = fluidbook.datas.pages; + if (last % 2 == 1) { + last--; + } + if (page >= last) { + $this.changeVisibility('lastpage', false); + } + } + $this.changePage(page); + }); + + $(fluidbook).on('fluidbook.page.change.end', function (e, page) { + if ($this.hideOnFirstPage) { + if (page > 1) { + $this.changeVisibility('firstpage', true); + } + } + if ($this.hideOnLastPage) { + var last = fluidbook.datas.pages; + if (last % 2 == 1) { + last--; + } + if (page < last) { + $this.changeVisibility('lastpage', true); + } + } + }); + } + }, + + changeVisibility: function (type, visible) { + this.visibility[type] = visible; + var tabsvisible = true; + $.each(this.visibility, function (k, v) { + if (!v) { + tabsvisible = false; + return false; + } + }); + + if (!tabsvisible) { + this.cont.addClass('hide'); + } else { + this.cont.removeClass('hide'); + } + + this.hideEdges(tabsvisible); + }, + + resize: function (data) { + var $this = this; + var css = {position: 'absolute'}; + var svgcss = {height: css.height}; + if (this.mode == 'side') { + var scale = data.fluidbookrect.height / this.naturalDimensions.height; + var w = this.naturalDimensions.width * scale; + + css.top = data.fluidbookrect.top; + css.height = data.fluidbookrect.height; + if (fluidbook.support.IE > 0) { + svgcss.width = w; + } + css.width = 'auto'; + if (this.align == 'right') { + css.left = data.fluidbookrect.left + data.fluidbookrect.width + (this.margin * scale); + } else if (this.align == 'left') { + css.left = data.fluidbookrect.left - w - this.margin; + } + } + + + // This trick allows to fix a dimension bug in ios + try { + this.svg.css(svgcss); + } catch (e) { + + } + this.cont.css(css); + + if (this.hideWhenOverlapingArrows) { + try { + var bbox = this.svg.find('#o1').get(0).getBoundingClientRect(); + if (this.align === 'left') { + if (bbox.left < data.arrowLeftRect.right) { + this.changeVisibility('arrows', false); + } else { + this.changeVisibility('arrows', true); + } + } + }catch (e) { + + } + } + }, + + }; + + jQuery.fn.tabs = function (data) { + return this.each(function () { + var $this = $(this); + if ($(this).data('tabs') === undefined) { + $(this).data('tabs', new JQtabs($this, data)); + } + }) + }; +})(jQuery); + diff --git a/Fluidbook-10doigts-Onglets/ONGLETS-SRC/10doigts/tabs.svg b/Fluidbook-10doigts-Onglets/ONGLETS-SRC/10doigts/tabs.svg new file mode 100644 index 0000000..0456098 --- /dev/null +++ b/Fluidbook-10doigts-Onglets/ONGLETS-SRC/10doigts/tabs.svg @@ -0,0 +1,581 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -- 2.39.5