diff --git a/.ruby-gemset b/.ruby-gemset deleted file mode 100644 index d8a6288..0000000 --- a/.ruby-gemset +++ /dev/null @@ -1 +0,0 @@ -jquery.silver_track diff --git a/.ruby-version b/.ruby-version deleted file mode 100644 index eca07e4..0000000 --- a/.ruby-version +++ /dev/null @@ -1 +0,0 @@ -2.1.2 diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index e69de29..0000000 diff --git a/COPYING b/COPYING deleted file mode 100644 index f485899..0000000 --- a/COPYING +++ /dev/null @@ -1,21 +0,0 @@ -Copyright 2012-2014 Túlio Ornelas. http://github.com/tulios - -MIT -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/Gemfile b/Gemfile deleted file mode 100644 index 954b816..0000000 --- a/Gemfile +++ /dev/null @@ -1,6 +0,0 @@ -source "https://rubygems.org" - -gem 'rake', '10.0.3' -gem 'jasmine', '1.3.2' -gem 'json' -gem 'sinatra' diff --git a/Gemfile.lock b/Gemfile.lock deleted file mode 100644 index 828245a..0000000 --- a/Gemfile.lock +++ /dev/null @@ -1,48 +0,0 @@ -GEM - remote: https://rubygems.org/ - specs: - childprocess (0.3.9) - ffi (~> 1.0, >= 1.0.11) - diff-lcs (1.2.4) - ffi (1.8.1) - jasmine (1.3.2) - jasmine-core (~> 1.3.1) - rack (~> 1.0) - rspec (>= 1.3.1) - selenium-webdriver (>= 0.1.3) - jasmine-core (1.3.1) - json (1.7.5) - multi_json (1.7.2) - rack (1.5.2) - rack-protection (1.3.2) - rack - rake (10.0.3) - rspec (2.13.0) - rspec-core (~> 2.13.0) - rspec-expectations (~> 2.13.0) - rspec-mocks (~> 2.13.0) - rspec-core (2.13.1) - rspec-expectations (2.13.0) - diff-lcs (>= 1.1.3, < 2.0) - rspec-mocks (2.13.1) - rubyzip (0.9.9) - selenium-webdriver (2.32.1) - childprocess (>= 0.2.5) - multi_json (~> 1.0) - rubyzip - websocket (~> 1.0.4) - sinatra (1.3.3) - rack (~> 1.3, >= 1.3.6) - rack-protection (~> 1.2) - tilt (~> 1.3, >= 1.3.3) - tilt (1.3.3) - websocket (1.0.7) - -PLATFORMS - ruby - -DEPENDENCIES - jasmine (= 1.3.2) - json - rake (= 10.0.3) - sinatra diff --git a/README.md b/README.md index 3dcaddc..66e2ba4 100644 --- a/README.md +++ b/README.md @@ -1,31 +1,17 @@ -# SilverTrack -### A smart and very extensible sliding carousel +# jQuery.silver_track -SilverTrack is a jQuery plugin designed to be extensible through other plugins. It has a small core and comes with very useful plugins. -Refer to the [jQuery SilverTrack website](http://tulios.github.com/jquery.silver_track/) for documentation and examples. +## Setup -## Tests - -#### Setup - -```ruby -bundle install -``` - -#### Running - -```ruby -rake jasmine:ci +```sh +gem install jekyll --no-ri --no-rdoc ``` -Or to run through the browser +## Generating pages -```ruby -rake jasmine +```sh +jekyll serve --watch ``` -and acess localhost:8888 - -## License +URL -See [COPYING](https://github.com/tulios/jquery.silver_track/blob/master/COPYING) for more details. + http://localhost:4000/ diff --git a/Rakefile b/Rakefile deleted file mode 100644 index ebe2be7..0000000 --- a/Rakefile +++ /dev/null @@ -1,11 +0,0 @@ -begin - require 'yaml' - require 'jasmine' - load 'jasmine/tasks/jasmine.rake' -rescue LoadError - task :jasmine do - abort "Jasmine is not available. In order to run jasmine, you must: (sudo) gem install jasmine" - end -end - -task :default => ["jasmine:ci"] diff --git a/_config.yml b/_config.yml new file mode 100644 index 0000000..35c1373 --- /dev/null +++ b/_config.yml @@ -0,0 +1,4 @@ +safe: true +lsi: false +highlighter: pygments +permalink: /:categories/:title.html diff --git a/_includes/footer.html b/_includes/footer.html new file mode 100644 index 0000000..9a02e90 --- /dev/null +++ b/_includes/footer.html @@ -0,0 +1,10 @@ + + + + + + diff --git a/_includes/head.html b/_includes/head.html new file mode 100644 index 0000000..a83a8b1 --- /dev/null +++ b/_includes/head.html @@ -0,0 +1,49 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {% if page.title %}{{ page.title }} - jQuery.silver_track {% else %}jQuery.silver_track{% endif %} + + + +
+
+ +
+

jQuery.silver_track

+

A smart and very extensible jquery sliding carousel

+
+ +
+ Download .zip + Download .tar.gz + View on GitHub +
+ + {% include menu.html %} diff --git a/_includes/menu.html b/_includes/menu.html new file mode 100644 index 0000000..e5d7437 --- /dev/null +++ b/_includes/menu.html @@ -0,0 +1,38 @@ + diff --git a/_layouts/main.html b/_layouts/main.html new file mode 100644 index 0000000..42abc0e --- /dev/null +++ b/_layouts/main.html @@ -0,0 +1,12 @@ +{% assign root_path = '../' %} +{% include head.html %} + +

+ {{ page.title }} +

+ +
+ {{ content }} +
+ +{% include footer.html %} diff --git a/_posts/how_tos/2014-06-07-getting-started.html b/_posts/how_tos/2014-06-07-getting-started.html new file mode 100644 index 0000000..c6540b8 --- /dev/null +++ b/_posts/how_tos/2014-06-07-getting-started.html @@ -0,0 +1,107 @@ +--- +layout: main +title: Getting Started +category: how_tos +--- + + + +

Let's setup a track with the navigator plugin. We will use a very simple markup, SilverTrack receives a container with your items, in our case, '.slider-container' and it leaves up to you to control the view port, so we will use '.view-port' to control de visibility. It also requires 'position: absolute' of your items

+ +{% highlight html %} +
+ + +
+
+
+
+ +
+
+ + + + +
+{% endhighlight %} + +{% highlight css %} +.view-port { + width: 960px; + overflow: hidden; + position: relative; +} +.slider-container { + position: relative; + height: 138px; + margin: 0; + padding: 0; +} +.item { + position: absolute; + width: 234px; + height: 138px; + margin-right: 8px +} +{% endhighlight %} + +

+After the minimum markup and css we will create our track. +

+ +{% highlight js %} +var container = $(".my-track"); +var track = container.find(".slider-container").silverTrack(); + +// install the plugins you want, in our case Navigator +track.install(new SilverTrack.Plugins.Navigator({ + prev: $("a.prev", container), + next: $("a.next", container) +})); + +track.start(); +{% endhighlight %} + +

+and it's done! +

+ +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ + +
+ +

+actually we add some css for the pagination arrows... +

+ +

+To improve the performance of the animations try the css3 animation plugin. +

+ +

+To learn how to use the other plugins, create your own plugin, use the SilverTrack Recipes to improve the creation of multiple tracks and for a more advanced use (options, methods, callbacks, etc) take a look at the menu. +

+ + diff --git a/_posts/how_tos/2014-06-08-creating-a-plugin.html b/_posts/how_tos/2014-06-08-creating-a-plugin.html new file mode 100644 index 0000000..31fd67c --- /dev/null +++ b/_posts/how_tos/2014-06-08-creating-a-plugin.html @@ -0,0 +1,178 @@ +--- +layout: main +title: Creating a plugin +category: how_tos +--- + + + +

+SilverTrack was designed to be extensible through plugins, so it provides a clean way to define one. To explain the internals of the missing art of plugin crafters we will create an example plugin that presents an alert to the user when an item is clicked. To create our plugin we will use the method $.silverTrackPlugin, this method receives the plugin name and an object that will handle all the callbacks during the life cycle of our track. +

+ +{% highlight js %} +$.silverTrackPlugin("PluginName", { + defaults: { + attribute: "default value" + }, + + /* + * Constructor + * options already merged with defaults + */ + initialize: function(options) {} + // more callbacks +}); +{% endhighlight %} + +

+For our plugin, let's assume the following code: +

+ +{% highlight js %} +$.silverTrackPlugin("ConfirmWhenItemClicked", { + defaults: { + message: "Really?" + }, + + initialize: function(options) { + this.options = options; + }, + + beforeStart: function(track) { + var self = this; + var itemSelector = "." + track.options.itemClass; + track.container.find(itemSelector).off("click").click(function(e) { + if (!confirm(self.options.message)) { + e.preventDefault(); + } + }); + } +}); +{% endhighlight %} + +

+We will use the same markup of the getting started track, just surrounding the images with a link. The code to create the track and install our plugin is: +

+ +{% highlight js %} +$(function() { + var container = $(".my-track"); + var track = container.find(".slider-container").silverTrack(); + + // Look at this guy, it will rule the world! + track.install(new SilverTrack.Plugins.ConfirmWhenItemClicked()); + + track.start(); +}); +{% endhighlight %} + +

+and presto! +

+ +
+
+
+
+
+
+
+
+
+
+ +

+For a complete list of callbacks and their usage check the table below. +

+ +

+ Available callbacks +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
namedescriptionarguments
initializeIt is the plugin constructor, it will receive the arguments passed to the plugin during the instantiationoptions - already merged with it's defaults
onInstallDiferent from initialize, this callback is called when your plugin is installed into a track, so this is the perfect moment to configure the track before it even startstrack
beforeStartIt is called when the track receives the method starttrack
afterStartIt is called after the track is fully startedtrack
afterRestartIs is called after the track restartstrack
onTotalPagesUpdateCalled when the totalPages is manual updated through the track method updateTotalPagestrack
beforeAnimationIt is called before any animations. The event object has which event was trigged (prev/next) along with page, cover and the itemstrack, event1
afterAnimationIs is called after any animationstrack, event1
beforePaginationIt is called before any pagination, it happens before any animationtrack, event1
beforeAdjustHeightIt is called only if the track parameter autoHeight is true, the default is false. Is is called before the height adjustment. The event object has the new heighttrack, event2
afterAdjustHeightIt is called only if the track parameter autoHeight is true, the default is false. Is is called after the height adjustment. The event object has the new heighttrack, event2
+ +

+Event 1: beforeAnimation, afterAnimation and beforePagination +

+ +{% highlight js %} +{ + name: "prev", // or "next" + page: 1, + cover: false, + items: [] +} +{% endhighlight %} + +

+Event 2: beforeAdjustHeight and afterAdjustHeight +

+ +{% highlight js %} +{ + items: [], + newHeight: 150 +} +{% endhighlight %} diff --git a/_posts/how_tos/2014-06-09-defining-a-recipe.html b/_posts/how_tos/2014-06-09-defining-a-recipe.html new file mode 100644 index 0000000..2408a35 --- /dev/null +++ b/_posts/how_tos/2014-06-09-defining-a-recipe.html @@ -0,0 +1,201 @@ +--- +layout: main +title: Defining a recipe +category: how_tos +--- + + + +

+With great plugins comes great responsabilities. In some cases we have a lot of tracks in a page and some of them may have different plugins (or lots of them) and configurations, to enhance the creation in these cases we created SilverTrackRecipes. It is a way to define a track recipe, with all its particularities, and refer to that recipe later, using a much simplified interface. To allow these creations we will use the method $.silverTrackRecipes to define the recipes and $.silverTrackRecipes.create to refer to one recipe and create the track. +

+ +

+$.silverTrackRecipes will receive a string (the name of your recipe) and a function. This function will receive a factory object that will be responsible to assemble your track in a moment of need. The factory object has two methods, createTrack and installPlugins, you could use just one or both of them. The method createTrack should only be used when you want to customize the track initialization, the method will receive the element (track container) and an options object with your own options. It must return the new track. installPlugins will receive the already initialized track and the same options of createTrack, you should install the plugins you want here. +

+ +

+We will create a recipe with the basic track we learn at getting started, let's call it, humm..., basic. + +{% highlight js %} +$.silverTrackRecipes("basic", function(factory) { + factory.createTrack(function(element, options) { + // Let's tweak a little bit this track + return element.silverTrack({ + easing: options.easing || "easeInOutQuad", + duration: options.duration || 600 + }); + }); + + factory.installPlugins(function(track, options) { + var parent = track.container.parents(".track"); + track.install(new SilverTrack.Plugins.Navigator({ + prev: $("a.prev", parent), + next: $("a.next", parent) + })); + }); +}); +{% endhighlight %} + +

+With all recipes defined, in our case just "basic", we can create a new instance of SilverTrack using one of these recipes. Look that in our recipe we have a default easing function and duration but is possible to set another values, let's create three tracks, each one with a different pair of values. For a more generic solution let's keep the recipe name and options in data attributes, like: +

+ +{% highlight html %} +
+
+
+
+ +
+
+
+{% endhighlight %} + +

+the "boot" code: +

+ +{% highlight js %} +$(".track").each(function() { + var container = $(this).find(".slider-container"); + var recipe = container.data("recipe"); + var opts = container.data("opts"); + $.silverTrackRecipes.create(recipe, container, opts).start(); +}); +{% endhighlight %} + +

+and the magic happens! +

+ +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ + +
+ +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ + +
+ +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ + +
+ +

+Chaining Recipes +

+ +

+It is very common to have more complex recipes that are just variations of the basic one. To exemplify this case we will create a "complex" recipe that installs the BulletNavigator plugin, take a look at the code bellow. +

+ +{% highlight js %} +$.silverTrackRecipes("complex", function(factory) { + factory.createTrack(function(element, options) { + return $.silverTrackRecipes.create("basic", element, options); + }); + + factory.installPlugins(function(track, options) { + track.install(new SilverTrack.Plugins.BulletNavigator({ + container: $(".bullet-pagination", track.container.parents(".track")) + })); + }); +}); +{% endhighlight %} + +

+With our current "boot" code we just need to change data-recipe to "complex", and it's done! +

+ +{% highlight html %} +
+
+
+
+ +
+
+
+{% endhighlight %} + +

+and presto! +

+ +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ +
+ + +
diff --git a/_posts/plugins/2014-06-07-navigator.html b/_posts/plugins/2014-06-07-navigator.html new file mode 100644 index 0000000..4d97fbc --- /dev/null +++ b/_posts/plugins/2014-06-07-navigator.html @@ -0,0 +1,88 @@ +--- +layout: main +title: Navigator +category: plugins +--- + + + +

+This plugin provides a simple way to attach the next and previous actions. +

+ +

+ Options +

+ + + + + + + + + + + + + + + + + + + + + + +
namedescriptiondefault
disabledClassClass applied to disable the navigation elementdisabled
prevElement that will receive the "previous" function
nextElement that will receive the "next" function
+ +

+ Callbacks +

+ + + + + + + + + + + + +
namedescriptionarguments
beforePaginationIt is called before any pagination, it happens before any animation. To see the format of event go to Creating a plugin for more referencetrack, event
+ +

+ Installation +

+ +{% highlight js %} +track.install(new SilverTrack.Plugins.Navigator({ + prev: $(".my-track a.prev"), + next: $(".my-track a.next") +})); +{% endhighlight %} + +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ + +
diff --git a/_posts/plugins/2014-06-08-bullet-navigator.html b/_posts/plugins/2014-06-08-bullet-navigator.html new file mode 100644 index 0000000..a19ecf9 --- /dev/null +++ b/_posts/plugins/2014-06-08-bullet-navigator.html @@ -0,0 +1,67 @@ +--- +layout: main +title: Bullet Navigator +category: plugins +--- + + + +

+This plugin provides a simple way to create random navigation links. +

+ +

+ Options +

+ + + + + + + + + + + + + + + + + + + + + + +
namedescriptiondefault
bulletClassClass applied to each "bullet"bullet
activeClassClass applied to the active "bullet"active
containerContainer to append the navigation links
+ +

+ Installation +

+ +{% highlight js %} +track.install(new SilverTrack.Plugins.BulletNavigator({ + container: $(".bullet-pagination") +})); +{% endhighlight %} + +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ +
+
diff --git a/_posts/plugins/2014-06-09-remote-content.html b/_posts/plugins/2014-06-09-remote-content.html new file mode 100644 index 0000000..3d6ffc7 --- /dev/null +++ b/_posts/plugins/2014-06-09-remote-content.html @@ -0,0 +1,355 @@ +--- +layout: main +title: Remote Content +category: plugins +--- + + + + + +

+This plugin provides a way to load content through ajax. Example in the end of the page. +

+ +

+ Options +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
namedescriptiondefault
lazyIt determines if RemoteContent will fetch the first page after the track starts or just when the user navigate to a page without cache. You will usually set this to false when you render your first page with the track and get the other items through ajaxtrue
prefetchPagesThe amount of pages that will be prefetched ahead of time. It is based on current page so if you have configured "prefetchPages: 2" it will start loading 3 pages (the first + 2) and will keep the distance of 2 pages until the end, so when the current page is 2 there will be 4 loaded pages and so on0
typeThe type of request to make ("POST" or "GET"). This parameter is sent direct to ajaxFunctionGET
paramsData to be sent to the server. This parameter is sent to option "data" of ajaxFunction{}
urlA string containing the URL to which the request is sent or a function that returns an url. If this option is a function, it will receive a reference of track, the page number and the perPage value, if not RemoteContent will try to replace the substrings {page} and {perPage} with the current values
ajaxFunctionA custom function for ajax. It defaults to $.ajax, if defined the provided function will receive the same options of $.ajax. It allows other ajax implementations such as ajaxQ or something based on promises$.ajax
+ +

+ Callbacks +

+

+ * Take a look at the opts values after the table of callbacks +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
namedescriptionarguments
beforeStartCalled before the track startstrack
beforeSendIt is a pre-request callback, it could be used to include spinners/loaders and do whatever you want before the requesttrack, jqXHR, settings, opts
beforeAppendCalled before the content generated by the processor is attached to the DOMtrack, items, opts
afterAppendCalled after items are attached to the DOM and their positions were updatedtrack, items, opts
processIt is a function that will process the data loaded by the server and return an array of DOM items that will be appended to the DOMtrack, perPage, data, opts
updateTotalPagesIt will be called after the afterAppend callback to update the total pages of the track based on the data loaded by the servertrack, data
onErrorCalled whenever an error happens with the requesttrack, jqXHR, textStatus, errorThrown, opts
+ +

+ * Possible opts values:
+ {% highlight js %} +{prefetch: false} +// or +{prefetch: true, currentPage: 1} + {% endhighlight %} +

+ +

+ Methods +

+ + + + + + + + + + + + +
namedescriptionparameters
reloadReload the content of track. This method flushes the cache and removes the items. If the track is lazy the first page is fetched after the reload
+ +

Example

+ +

+For our example, we will use a server called "echo" that responds with the same JSON that we set through the parameter json, it will also return the total pages number that we set with the parameter total_pages. +

+ +

+Because we are lazy people we will use the lazy option true, that is already set by default, thus the markup will be like: +

+ +{% highlight html %} +
+
+
+ +
+
+ + +
+{% endhighlight %} + +

+For this examples we will need some support functions. We need to generate a fake json to allow the echo server to return json and we will also need to generate the appropriate url with the json parameter set. This is just necessary to the example, in your code you will point to your service url and won't need any fake json generator. +

+ +{% highlight js %} +// Let's create a function to create the urls for our "echo" test server +var urlToEchoServer = function(track, page, perPage) { + var jsonText = escape(JSON.stringify(fakeJsonCreator(page, perPage))); + var echoServerHost = "http://echo-server.herokuapp.com"; + return echoServerHost + "/echo/json/" + page + "?json=" + jsonText + "&total_pages=5"; +} + +// Support function for our test +var fakeJsonCreator = function(page, perPage) { + var photoTypes = ["food", "people", "nature", "sports"]; + var items = []; + for (var i = 0; i < perPage; i++) { + items.push({img_url: "http://lorempixel.com/224/128/" + photoTypes[i]}); + } + + return items; +} +{% endhighlight %} + +

+Then we will create our processor, the function that will transform the data from the server into an array of DOM elements, and install our plugin +

+ +{% highlight js %} +// Let's create our processor, the function that will transform the data +// from the server into an array of DOM elements +var processor = function(track, perPage, json) { + var array = []; + + for (var i = 0; i < perPage; i++) { + if (json.data[i] === undefined) { + break; + } + + array.push( + $("
", {"class": "item"}).append($("", {"src": json.data[i].img_url})) + ); + } + + return array; +} + +// Then we install the plugin +track.install(new SilverTrack.Plugins.RemoteContent({ + url: urlToEchoServer, + process: processor, + + beforeStart: function(track) { + track.container.parent().append($("
", {"class": "loading"})); + }, + + beforeSend: function(track) { + $(".loading", track.container.parent()).fadeIn(); + }, + + beforeAppend: function(track, items) { + $(".loading", track.container.parent()).hide(); + }, + + updateTotalPages: function(track, json) { + track.updateTotalPages(json.total_pages); + } +})); +{% endhighlight %} + +

+and it's done! +

+ +
+
+
+
+
+ + +
+ +

Reloading with another content

+ +

+ The RemoteContent plugin has a method to reload the content of the track flushing all the cache, with this method we can load another content to the track just changing the URL before call it. We will use some helper functions like the first example, the only modification is that the new function will generate an URL for a one type only. +

+ +

+ The code of the buttons will be like: +

+ +{% highlight js %} +$(".commands button[data-type]").each(function() { + var button = $(this); + var type = button.data("type"); + + button.off("click").click(function(e) { + e.preventDefault(); + var plugin = track.findPluginByName("RemoteContent"); + plugin.options.url = function(track, page, perPage) { + // URL with the selected type + return urlToEchoServer(track, page, perPage, type); + } + + plugin.reload(); + }); +}); +{% endhighlight %} + +
+
    +
  • +
  • +
  • +
  • +
+
+ +
+
+
+
+
+ + +
+ +

Loading content ahead of time

+ +

+ The "prefetchPages" optimizes the load of pages, it will load some pages before the user action so that when the user click the "next" button it will paginate instantly without the load time. This example uses the same structure of the other examples with three differences: +

+ +

+ 1º it enables the "prefetchPages", in this example with 2 pages ahead of time +

+ +{% highlight js %} +// ... +track.install(new SilverTrack.Plugins.RemoteContent({ + url: urlToEchoServer, + process: processor, + prefetchPages: 2, + // ... +}); +{% endhighlight %} + +

+ 2º and 3º it avoids the loading markup when the page is prefetched. +

+ +{% highlight js %} +// ... +track.install(new SilverTrack.Plugins.RemoteContent({ + // ... + beforeSend: function(track, jqXHR, settings, opts) { + if (opts.prefetch) { + return; + } + + $(".loading", track.container.parent()).fadeIn(); + }, + + beforeAppend: function(track, items, opts) { + if (!!opts.prefetch) { + return; + } + + $(".loading", track.container.parent()).hide(); + }, + + // ... +}); +{% endhighlight %} + +

+ Take a look at the network tab of your browser to follow the requests. +

+ +
+
+
+
+
+ + +
diff --git a/_posts/plugins/2014-06-09-responsive-hub-connector.html b/_posts/plugins/2014-06-09-responsive-hub-connector.html new file mode 100644 index 0000000..d312845 --- /dev/null +++ b/_posts/plugins/2014-06-09-responsive-hub-connector.html @@ -0,0 +1,49 @@ +--- +layout: main +title: ResponsiveHub Connector +category: plugins +--- + +

+This plugin provides an integration with ResponsiveHub, a plugin that defines it self as "JavaScript goodies for Responsive Design". +

+ +

+This plugin requires ResponsiveHub js and Moderniz.mediaqueries. You will find the Modernizr feature in the lib directory of SilverTrack repository but you could use your own Modernizr files. +

+ +

+ Options +

+ + + + + + + + + + +
namedescription
layoutsThe resolution names configured in responsiveHub. You really should read the responsiveHub readme
+ +

+ Callbacks +

+ + + + + + + + + + + + + + + + +
namedescriptionarguments
onReadyThe resolution names configured in responsiveHub. You really should read the responsiveHub readmetrack, options, event
onChangeThe resolution names configured in responsiveHub. You really should read the responsiveHub readmetrack, options, event
diff --git a/_posts/plugins/2014-06-10-css3-animation.html b/_posts/plugins/2014-06-10-css3-animation.html new file mode 100644 index 0000000..109a777 --- /dev/null +++ b/_posts/plugins/2014-06-10-css3-animation.html @@ -0,0 +1,173 @@ +--- +layout: main +title: Css3 Animation +category: plugins +--- + + + +

+This plugin replaces the animation function of SilverTrack to work with css3 transtions, it will provide an stunning amount of performance for mobile devices and even desktop browsers. Note that due the way css3 animations work the option restart({animate: false}) of SilverTrack will not work. It will automatically fallback to javascript animations if transitions are not available in the browser. +

+ +

+This plugin requires Moderniz.transform3d. You will find just this feature in the lib directory of SilverTrack repository but you could use your own Modernizr files. +

+ +

+ Options +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
namedescriptiondefault
durationUnitThe unit used for the animations. The possible values are: ms and sms
delayUnitThe unit used for the delay property. It automatically fallback to durationUnit if not setnull
setupParentConfigure the css3 properties to allow hardware acceleration in the parent of the container. It might also be done directly through the css file, so this option could be disabledtrue
setupTransitionPropertyConfigure the css3 transition-property to the container. It might also be done directly through the css file, so this option could be disabledtrue
setupTransitionDurationConfigure the css3 transition-duration to the container. It might also be done directly through the css file, so this option could be disabledtrue
setupTransitionTimingFunctionConfigure the css3 transition-timing-function to the container, it already converts the easing names (easeInOutQuart, easeInCubic, etc) to proper cubic-bezier functions. It might also be done directly through the css file, so this option could be disabledtrue
setupTransitionDelayConfigure the css3 transition-delay to the container. It might also be done directly through the css file, so this option could be disabledtrue
slideDelayThe delay used between the transitions, note that delay it is not the same as the duration, this is the time that the browser will wait before the animation starts. It might also be done directly through the css file, if it is the case the option setupTransitionDuration should be disabled0
autoHeightDurationThis option configures the duration of the height adjustment animation if the property autoHeight of track is set to true. It might also be done directly through the css file but be aware that this option is correctly configured with the duration of the slide animation, make sure that both will work. It automatically fallback to the option duration of the tracknull
autoHeightEasingThis option configures the easing function of the height adjustment animation if the property autoHeight of the track is set to true. It might also be done directly through the css file but be aware that this option convert the easing name (easeInOutQuart, easeInCubic, etc) to the proper cubic-bezier function and is configured with the easing function of the slide animation, make sure that both will work. It automatically fallback to the option easing of the tracknull
autoHeightDelayThis option configures the delay of the height adjustment animation if the property autoHeight of the track is set to true. It might also be done directly through the css file but be aware that this option is correctly configured with the delay of the slide animation, make sure that both will work. It automatically fallback to the option slideDelaynull
+ +

+ Installation +

+ +{% highlight js %} +track.install(new SilverTrack.Plugins.Css3Animation()); +{% endhighlight %} + +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ + +
+ +

+Using the easing 'easeInOutQuad' in the track with 1s duration +

+ +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ + +
+ +

+Using a track with mode "vertical" and autoHeight true. Let's configure different options to the animation. +

+ +{% highlight js %} +track.install(new SilverTrack.Plugins.Css3Animation({ + delayUnit: "s", + autoHeightDuration: 300, + autoHeightEasing: "easeInOutCubic", + autoHeightDelay: 1 +})); +{% endhighlight %} + +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ + +
diff --git a/_posts/plugins/2015-01-27-circular-navigator.html b/_posts/plugins/2015-01-27-circular-navigator.html new file mode 100644 index 0000000..393e596 --- /dev/null +++ b/_posts/plugins/2015-01-27-circular-navigator.html @@ -0,0 +1,172 @@ +--- +layout: main +title: Circular Navigator +category: plugins +--- + + + +

+This plugin provides a simple way to make navigation circular. +

+ +

+ Options +

+ + + + + + + + + + + + + + + + + + + + + + +
namedescriptiondefault
autoPlayAllows your track to foward one page by 'duration option' time. It automatically disabled when mouse is over the track.false
durationtime to auto play in milliseconds3000
clonedClassClass applied to the cloned items that makes track circular"cloned"
+ +

+ Installation +

+ +

+Circular Navigator Plugin requires the Navigator Plugin +

+ +{% highlight js %} +track.install(new SilverTrack.Plugins.Navigator({ + prev: $(".my-track a.prev"), + next: $(".my-track a.next") +})); + +track.install(new SilverTrack.Plugins.CircularNavigator()); +{% endhighlight %} + +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ + +
+ +

+ Give life to your track +

+ +

In this way, autoplay allows your track to foward one page by 'duration option' time. It automatically disabled when mouse is over the track. + +{% highlight js %} + track.install(new SilverTrack.Plugins.Navigator({ + prev: $(".my-track a.prev"), + next: $(".my-track a.next") +})); + +track.install(new SilverTrack.Plugins.CircularNavigator({ + autoPlay: true, + duration: 5 * 1000 // 5s +})); +{% endhighlight %} + +

+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ + +
+ +

+ Connect with Bullet Navigator Plugin +

+ +

In this way, you can easily control pages and be aware of which is the current page. + +{% highlight js %} + track.install(new SilverTrack.Plugins.Navigator({ + prev: $("a.prev", container), + next: $("a.next", container) + })); + + track.install(new SilverTrack.Plugins.Css3Animation()); + + track.install(new SilverTrack.Plugins.CircularNavigator({ + autoPlay: true, + duration: 5000 + })); + + track.install(new SilverTrack.Plugins.BulletNavigator({ + container: $(".bullet-pagination") + })); +{% endhighlight %} + +

+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ + + +
+
+ diff --git a/_posts/root/2014-03-11-methods.html b/_posts/root/2014-03-11-methods.html new file mode 100644 index 0000000..2302616 --- /dev/null +++ b/_posts/root/2014-03-11-methods.html @@ -0,0 +1,134 @@ +--- +layout: main +title: Methods +category: root +--- + + + +

+All the methods must be called on the SilverTrack instance. It is possible to retrieve the instance through the container used to create the track, example: +

+ +{% highlight js %} +// It will only create a new instance, in the first time, or retrieves an existing one +var track = $(".slider-container").silverTrack(); + +// Calling methods +track.hasPrev(); +track.prev(); +track.goToPage(3); +// ... +{% endhighlight %} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
namedescriptionparameters
startStarts SilverTrack
goToPageGoes to a specific page when it existsmpage
nextGoes to the next page when it exists
prevGoes to the previous page when it exists
hasNextReturns true if next page existfalse
hasPrevReturns true if previous page exist
restartRestarts the position of the items, by default goes to the first page. This method accepts an opts object with page, keepCurrentPage and animate attributes. Default: {page: 1, keepCurrentPage: false, animate: false}opts
installInstalls a plugin. Check out the how to Creating a pluginplugin
reloadItemsNullifies the items cache forcing the plugin to reload
updateTotalPagesDisables the calculation of totalPages and defines the new one with the informed numbertotalPages
findPluginByNameFinds an installed plugin by its name. It returns null if the plugin is not installed. Ex: track.findPluginByName("Navigator")name
+ +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ + +
+ +
+
Commands:
+
    +
  • +
  • +
+
    +
  • +
  • +
+
    +
  • +
  • +
+
+
    +
  • +
  • +
  • +
  • +
+
+ +
+ + diff --git a/_posts/root/2014-03-13-options.html b/_posts/root/2014-03-13-options.html new file mode 100644 index 0000000..c904634 --- /dev/null +++ b/_posts/root/2014-03-13-options.html @@ -0,0 +1,223 @@ +--- +layout: main +title: Options +category: root +--- + + + +

+All the options must be passed in the initialization and will be available at track.options +

+ +{% highlight js %} +$(".slider-container").silverTrack({ + perPage: 4, + itemClass: "item", + mode: "horizontal", + autoHeight: false, + cover: false, + duration: "slow", + easing: "swing" +}); +{% endhighlight %} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
namedescriptiondefault
perPageThe amount of itens to display4
itemClassThe class name that will be used to find the itemitem
modeThe direction of pagination (horizontal or vertical)horizontal
animationAxisThe direction of the animation (x or y). To animate in "y" axis you will need the mode "vertical" toox
autoHeightIf it will adjust the track height after each paginationfalse
coverWhen set to true, the plugin will consider the first page as a cover and will consider it as one itemfalse
easingAnimation function used by SilverTrack. This function will be used by $.animate, so you could use any plugin that adds easing functions. Ex: jQuery Easingswing
durationThe duration used by the animation function600
animateFunctionIf set this function will be used instead of $.animate. The function will receive movement, duration, easing and afterCallback. The movement object will be {left: someNumber} or {height: someNumber}. For an example of how to replace the animation function take a look at css3 animation pluginnull
+ +

+Using: +

+ +{% highlight js %} +{itemClass: "my-item", cover: true, easing: "easeInOutQuad", duration: 600} +{% endhighlight %} + +
+
+
+
+
+

Pick the best cover

+ because it will occupy the whole first page, but it adds a nice touch of refinement +
+ +
+
+
+
+
+
+
+
+
+ +
+
+
+
+ +
+
+
+
+ + +
+ +

+Using: +

+ +{% highlight js %} +{itemClass: "small-item", perPage: 5, mode: "vertical"} +{% endhighlight %} + +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ + +
+ +

+Using: +

+ +{% highlight js %} +{itemClass: "small-item", perPage: 5, mode: "vertical", animationAxis: "y"} +{% endhighlight %} + +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ + + +
+
+ +

+Using: +

+ +{% highlight js %} +{itemClass: "small-item", cover: true, perPage: 5, mode: "vertical", animationAxis: "y"} +{% endhighlight %} + +
+
+
+
+
+

Arrow down

+
+ +
+
+
+
+
+
+
+
+
+
+
+
+ + + +
+
diff --git a/_site/README.md b/_site/README.md new file mode 100644 index 0000000..66e2ba4 --- /dev/null +++ b/_site/README.md @@ -0,0 +1,17 @@ +# jQuery.silver_track + +## Setup + +```sh +gem install jekyll --no-ri --no-rdoc +``` + +## Generating pages + +```sh +jekyll serve --watch +``` + +URL + + http://localhost:4000/ diff --git a/_site/how_tos/creating-a-plugin.html b/_site/how_tos/creating-a-plugin.html new file mode 100644 index 0000000..285672e --- /dev/null +++ b/_site/how_tos/creating-a-plugin.html @@ -0,0 +1,287 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Creating a plugin - jQuery.silver_track + + + +
+
+ +
+

jQuery.silver_track

+

A smart and very extensible jquery sliding carousel

+
+ +
+ Download .zip + Download .tar.gz + View on GitHub +
+ + + + + +

+ Creating a plugin +

+ +
+ + +

+SilverTrack was designed to be extensible through plugins, so it provides a clean way to define one. To explain the internals of the missing art of plugin crafters we will create an example plugin that presents an alert to the user when an item is clicked. To create our plugin we will use the method $.silverTrackPlugin, this method receives the plugin name and an object that will handle all the callbacks during the life cycle of our track. +

+ +
$.silverTrackPlugin("PluginName", {
+  defaults: {
+    attribute: "default value"
+  },
+
+  /*
+   * Constructor
+   * options already merged with defaults
+   */
+  initialize: function(options) {}
+  // more callbacks
+});
+ +

+For our plugin, let's assume the following code: +

+ +
$.silverTrackPlugin("ConfirmWhenItemClicked", {
+  defaults: {
+    message: "Really?"
+  },
+
+  initialize: function(options) {
+    this.options = options;
+  },
+
+  beforeStart: function(track) {
+    var self = this;
+    var itemSelector = "." + track.options.itemClass;
+    track.container.find(itemSelector).off("click").click(function(e) {
+      if (!confirm(self.options.message)) {
+        e.preventDefault();
+      }
+    });
+  }
+});
+ +

+We will use the same markup of the getting started track, just surrounding the images with a link. The code to create the track and install our plugin is: +

+ +
$(function() {
+  var container = $(".my-track");
+  var track = container.find(".slider-container").silverTrack();
+
+  // Look at this guy, it will rule the world!
+  track.install(new SilverTrack.Plugins.ConfirmWhenItemClicked());
+
+  track.start();
+});
+ +

+and presto! +

+ +
+
+
+
+
+
+
+
+
+
+ +

+For a complete list of callbacks and their usage check the table below. +

+ +

+ Available callbacks +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
namedescriptionarguments
initializeIt is the plugin constructor, it will receive the arguments passed to the plugin during the instantiationoptions - already merged with it's defaults
onInstallDiferent from initialize, this callback is called when your plugin is installed into a track, so this is the perfect moment to configure the track before it even startstrack
beforeStartIt is called when the track receives the method starttrack
afterStartIt is called after the track is fully startedtrack
afterRestartIs is called after the track restartstrack
onTotalPagesUpdateCalled when the totalPages is manual updated through the track method updateTotalPagestrack
beforeAnimationIt is called before any animations. The event object has which event was trigged (prev/next) along with page, cover and the itemstrack, event1
afterAnimationIs is called after any animationstrack, event1
beforePaginationIt is called before any pagination, it happens before any animationtrack, event1
beforeAdjustHeightIt is called only if the track parameter autoHeight is true, the default is false. Is is called before the height adjustment. The event object has the new heighttrack, event2
afterAdjustHeightIt is called only if the track parameter autoHeight is true, the default is false. Is is called after the height adjustment. The event object has the new heighttrack, event2
+ +

+Event 1: beforeAnimation, afterAnimation and beforePagination +

+ +
{
+  name: "prev", // or "next"
+  page: 1,
+  cover: false,
+  items: []
+}
+ +

+Event 2: beforeAdjustHeight and afterAdjustHeight +

+ +
{
+  items: [],
+  newHeight: 150
+}
+ +
+ + + +
+
+ + + diff --git a/_site/how_tos/defining-a-recipe.html b/_site/how_tos/defining-a-recipe.html new file mode 100644 index 0000000..65c68b3 --- /dev/null +++ b/_site/how_tos/defining-a-recipe.html @@ -0,0 +1,310 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Defining a recipe - jQuery.silver_track + + + +
+
+ +
+

jQuery.silver_track

+

A smart and very extensible jquery sliding carousel

+
+ +
+ Download .zip + Download .tar.gz + View on GitHub +
+ + + + + +

+ Defining a recipe +

+ +
+ + +

+With great plugins comes great responsabilities. In some cases we have a lot of tracks in a page and some of them may have different plugins (or lots of them) and configurations, to enhance the creation in these cases we created SilverTrackRecipes. It is a way to define a track recipe, with all its particularities, and refer to that recipe later, using a much simplified interface. To allow these creations we will use the method $.silverTrackRecipes to define the recipes and $.silverTrackRecipes.create to refer to one recipe and create the track. +

+ +

+$.silverTrackRecipes will receive a string (the name of your recipe) and a function. This function will receive a factory object that will be responsible to assemble your track in a moment of need. The factory object has two methods, createTrack and installPlugins, you could use just one or both of them. The method createTrack should only be used when you want to customize the track initialization, the method will receive the element (track container) and an options object with your own options. It must return the new track. installPlugins will receive the already initialized track and the same options of createTrack, you should install the plugins you want here. +

+ +

+We will create a recipe with the basic track we learn at getting started, let's call it, humm..., basic. + +

$.silverTrackRecipes("basic", function(factory) {
+  factory.createTrack(function(element, options) {
+    // Let's tweak a little bit this track
+    return element.silverTrack({
+      easing: options.easing || "easeInOutQuad",
+      duration: options.duration || 600
+    });
+  });
+
+  factory.installPlugins(function(track, options) {
+    var parent = track.container.parents(".track");
+    track.install(new SilverTrack.Plugins.Navigator({
+      prev: $("a.prev", parent),
+      next: $("a.next", parent)
+    }));
+  });
+});
+ +

+With all recipes defined, in our case just "basic", we can create a new instance of SilverTrack using one of these recipes. Look that in our recipe we have a default easing function and duration but is possible to set another values, let's create three tracks, each one with a different pair of values. For a more generic solution let's keep the recipe name and options in data attributes, like: +

+ +
<div class="track">
+  <div class="view-port">
+    <div class="slider-container" data-recipe="basic" data-opts='{"easing": "easeInOutSine", "duration": 800}'>
+      <div class="item"><img src="http://lorempixel.com/230/134/nature/1/"></div>
+      <!-- items ... -->
+    </div>
+  </div>
+</div>
+ +

+the "boot" code: +

+ +
$(".track").each(function() {
+  var container = $(this).find(".slider-container");
+  var recipe = container.data("recipe");
+  var opts = container.data("opts");
+  $.silverTrackRecipes.create(recipe, container, opts).start();
+});
+ +

+and the magic happens! +

+ +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ + +
+ +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ + +
+ +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ + +
+ +

+Chaining Recipes +

+ +

+It is very common to have more complex recipes that are just variations of the basic one. To exemplify this case we will create a "complex" recipe that installs the BulletNavigator plugin, take a look at the code bellow. +

+ +
$.silverTrackRecipes("complex", function(factory) {
+  factory.createTrack(function(element, options) {
+    return $.silverTrackRecipes.create("basic", element, options);
+  });
+
+  factory.installPlugins(function(track, options) {
+    track.install(new SilverTrack.Plugins.BulletNavigator({
+      container: $(".bullet-pagination", track.container.parents(".track"))
+    }));
+  });
+});
+ +

+With our current "boot" code we just need to change data-recipe to "complex", and it's done! +

+ +
<div class="track">
+  <div class="view-port">
+    <div class="slider-container" data-recipe="complex" data-opts='{"easing": "easeInOutCubic", "duration": 700}'>
+      <div class="item"><img src="http://lorempixel.com/230/134/cats/1/"></div>
+      <!-- items ... -->
+    </div>
+  </div>
+</div>
+ +

+and presto! +

+ +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ +
+ + +
+ +
+ + + +
+
+ + + diff --git a/_site/how_tos/getting-started.html b/_site/how_tos/getting-started.html new file mode 100644 index 0000000..18f7c3e --- /dev/null +++ b/_site/how_tos/getting-started.html @@ -0,0 +1,220 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Getting Started - jQuery.silver_track + + + +
+
+ +
+

jQuery.silver_track

+

A smart and very extensible jquery sliding carousel

+
+ +
+ Download .zip + Download .tar.gz + View on GitHub +
+ + + + + +

+ Getting Started +

+ +
+ + +

Let's setup a track with the navigator plugin. We will use a very simple markup, SilverTrack receives a container with your items, in our case, '.slider-container' and it leaves up to you to control the view port, so we will use '.view-port' to control de visibility. It also requires 'position: absolute' of your items

+ +
<div class="track my-track">
+
+  <!-- SilverTrack requires only this part -->
+  <div class="view-port">
+    <div class="slider-container">
+      <div class="item"><img src="http://lorempixel.com/230/134/nature/1/"></div>
+      <div class="item"><img src="http://lorempixel.com/230/134/nature/2/"></div>
+      <!-- ... -->
+    </div>
+  </div>
+
+  <!-- My custom navigator links -->
+  <div class="pagination">
+    <a href="#" class="prev disabled"></a>
+    <a href="#" class="next disabled"></a>
+  </div>
+
+</div>
+ +
.view-port {
+  width: 960px;
+  overflow: hidden;
+  position: relative;
+}
+.slider-container {
+  position: relative;
+  height: 138px;
+  margin: 0;
+  padding: 0;
+}
+.item {
+  position: absolute;
+  width: 234px;
+  height: 138px;
+  margin-right: 8px
+}
+ +

+After the minimum markup and css we will create our track. +

+ +
var container = $(".my-track");
+var track = container.find(".slider-container").silverTrack();
+
+// install the plugins you want, in our case Navigator
+track.install(new SilverTrack.Plugins.Navigator({
+  prev: $("a.prev", container),
+  next: $("a.next", container)
+}));
+
+track.start();
+ +

+and it's done! +

+ +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ + +
+ +

+actually we add some css for the pagination arrows... +

+ +

+To improve the performance of the animations try the css3 animation plugin. +

+ +

+To learn how to use the other plugins, create your own plugin, use the SilverTrack Recipes to improve the creation of multiple tracks and for a more advanced use (options, methods, callbacks, etc) take a look at the menu. +

+ +
+ + + + + +
+
+ + + diff --git a/example/img/arrows.png b/_site/images/arrows.png similarity index 100% rename from example/img/arrows.png rename to _site/images/arrows.png diff --git a/_site/images/body-bg.png b/_site/images/body-bg.png new file mode 100644 index 0000000..d0618fe Binary files /dev/null and b/_site/images/body-bg.png differ diff --git a/_site/images/example/cover1.png b/_site/images/example/cover1.png new file mode 100644 index 0000000..69d4c24 Binary files /dev/null and b/_site/images/example/cover1.png differ diff --git a/_site/images/example/vertical_cover1.png b/_site/images/example/vertical_cover1.png new file mode 100644 index 0000000..b43c39c Binary files /dev/null and b/_site/images/example/vertical_cover1.png differ diff --git a/example/img/gh-icons.png b/_site/images/gh-icons.png similarity index 100% rename from example/img/gh-icons.png rename to _site/images/gh-icons.png diff --git a/_site/images/highlight-bg.jpg b/_site/images/highlight-bg.jpg new file mode 100644 index 0000000..4c4a78e Binary files /dev/null and b/_site/images/highlight-bg.jpg differ diff --git a/_site/images/hr.png b/_site/images/hr.png new file mode 100644 index 0000000..6c723a5 Binary files /dev/null and b/_site/images/hr.png differ diff --git a/_site/images/octocat-icon.png b/_site/images/octocat-icon.png new file mode 100644 index 0000000..f0ba137 Binary files /dev/null and b/_site/images/octocat-icon.png differ diff --git a/_site/images/tar-gz-icon.png b/_site/images/tar-gz-icon.png new file mode 100644 index 0000000..d50f34f Binary files /dev/null and b/_site/images/tar-gz-icon.png differ diff --git a/_site/images/zip-icon.png b/_site/images/zip-icon.png new file mode 100644 index 0000000..162c425 Binary files /dev/null and b/_site/images/zip-icon.png differ diff --git a/_site/index.html b/_site/index.html new file mode 100644 index 0000000..61cf9bc --- /dev/null +++ b/_site/index.html @@ -0,0 +1,246 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + jQuery.silver_track + + + +
+
+ +
+

jQuery.silver_track

+

A smart and very extensible jquery sliding carousel

+
+ +
+ Download .zip + Download .tar.gz + View on GitHub +
+ + + + + + + +
+

+ SilverTrack is a jQuery plugin designed to be extensible through other plugins. It has a small core and comes with very useful plugins +

+ +

+ For more examples and detailed documentation take a look at the menu or spending some time on getting started guide. +

+ +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ + +
+ +
+
+
+
+
+

Pick the best cover

+ because it will occupy the whole first page, but it adds a nice touch of refinement +
+ +
+
+
+
+
+
+
+
+
+
+
+
+
+ + +
+ +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ + +
+ +
+
+
+
+
+
+
+
+
+
+
+
+
+ + +
+ +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ + +
+
+ + + +
+
+ + + diff --git a/_site/javascripts/basic_example.js b/_site/javascripts/basic_example.js new file mode 100644 index 0000000..6532c1b --- /dev/null +++ b/_site/javascripts/basic_example.js @@ -0,0 +1,12 @@ +$(function() { + var container = $(".my-track"); + var track = container.find(".slider-container").silverTrack(); + + // install the plugins you want, in our case Navigator + track.install(new SilverTrack.Plugins.Navigator({ + prev: $("a.prev", container), + next: $("a.next", container) + })); + + track.start(); +}); diff --git a/_site/javascripts/creating_plugin_example.js b/_site/javascripts/creating_plugin_example.js new file mode 100644 index 0000000..4c3293d --- /dev/null +++ b/_site/javascripts/creating_plugin_example.js @@ -0,0 +1,34 @@ +$(function() { + // ========================================================================= + // Plugin definition + // ========================================================================= + $.silverTrackPlugin("ConfirmWhenItemClicked", { + defaults: { + message: "Really?" + }, + + initialize: function(options) { + this.options = options; + }, + + beforeStart: function(track) { + var self = this; + var itemSelector = "." + track.options.itemClass; + track.container.find(itemSelector).off("click").click(function(e) { + if (!confirm(self.options.message)) { + e.preventDefault(); + } + }); + } + }); + + // ========================================================================== + // Track initialization + // ========================================================================== + var container = $(".my-track"); + var track = container.find(".slider-container").silverTrack(); + + track.install(new SilverTrack.Plugins.ConfirmWhenItemClicked()); + + track.start(); +}); diff --git a/_site/javascripts/defining_recipe_example.js b/_site/javascripts/defining_recipe_example.js new file mode 100644 index 0000000..57cec5d --- /dev/null +++ b/_site/javascripts/defining_recipe_example.js @@ -0,0 +1,44 @@ +$(function() { + // ========================================================================== + // Defining recipes + // ========================================================================== + $.silverTrackRecipes("basic", function(factory) { + factory.createTrack(function(element, options) { + // Let's tweak a little bit this track + return element.silverTrack({ + easing: options.easing || "easeInOutQuad", + duration: options.duration || 600 + }); + }); + + factory.installPlugins(function(track, options) { + var parent = track.container.parents(".track"); + track.install(new SilverTrack.Plugins.Navigator({ + prev: $("a.prev", parent), + next: $("a.next", parent) + })); + }); + }); + + $.silverTrackRecipes("complex", function(factory) { + factory.createTrack(function(element, options) { + return $.silverTrackRecipes.create("basic", element, options); + }); + + factory.installPlugins(function(track, options) { + track.install(new SilverTrack.Plugins.BulletNavigator({ + container: $(".bullet-pagination", track.container.parents(".track")) + })); + }); + }); + + // ========================================================================== + // Track initialization + // ========================================================================== + $(".track").each(function() { + var container = $(this).find(".slider-container"); + var recipe = container.data("recipe"); + var opts = container.data("opts"); + $.silverTrackRecipes.create(recipe, container, opts).start(); + }); +}); diff --git a/_site/javascripts/home_examples.js b/_site/javascripts/home_examples.js new file mode 100644 index 0000000..ae951f3 --- /dev/null +++ b/_site/javascripts/home_examples.js @@ -0,0 +1,102 @@ +$(function() { + // Take a look at Recipes (http://tulios.github.io/jquery.silver_track/how_tos/defining-a-recipe.html) to avoid repetition + // ========================================================================= + // Sample 1 + // ========================================================================= + var container = $(".track.sample1"); + var track = container.find(".slider-container").silverTrack({duration: 800}); + + track.install(new SilverTrack.Plugins.Css3Animation()); + + track.install(new SilverTrack.Plugins.Navigator({ + prev: $("a.prev", container), + next: $("a.next", container) + })); + + track.start(); + + // ========================================================================= + // Sample 2 + // ========================================================================= + container = $(".track.sample2"); + track = container.find(".slider-container").silverTrack({ + itemClass: "my-item", + cover: true, + easing: "easeInOutQuad", + duration: 600 + }); + + track.install(new SilverTrack.Plugins.Css3Animation()); + + track.install(new SilverTrack.Plugins.Navigator({ + prev: $("a.prev", container), + next: $("a.next", container) + })); + + track.install(new SilverTrack.Plugins.BulletNavigator({ + container: $(".bullet-pagination") + })); + + track.start(); + + // ========================================================================= + // Sample 3 + // ========================================================================= + container = $(".track.sample3"); + track = container.find(".slider-container").silverTrack({ + duration: 600, + easing: "easeInOutQuad", + mode: "vertical", + autoHeight: true + }); + + track.install(new SilverTrack.Plugins.Navigator({ + prev: $("a.prev", container), + next: $("a.next", container) + })); + + track.install(new SilverTrack.Plugins.Css3Animation()); + + track.start(); + + // ========================================================================= + // Sample 4 + // ========================================================================= + container = $(".track.sample4"); + track = container.find(".slider-container").silverTrack({ + duration: 600, + easing: "easeInOutQuad", + mode: "vertical", + animationAxis: "y" + }); + + track.install(new SilverTrack.Plugins.Navigator({ + prev: $("a.prev", container), + next: $("a.next", container) + })); + + track.install(new SilverTrack.Plugins.Css3Animation()); + + track.start(); + + // ========================================================================= + // Sample 5 + // ========================================================================= + + container = $(".track.sample5"); + var track = container.find(".slider-container").silverTrack(); + + track.install(new SilverTrack.Plugins.Css3Animation()); + + track.install(new SilverTrack.Plugins.Navigator({ + prev: $("a.prev", container), + next: $("a.next", container) + })); + + track.install(new SilverTrack.Plugins.CircularNavigator({ + autoPlay: true, + duration: 5000 + })); + + track.start(); +}); diff --git a/_site/javascripts/libs/bootstrap.dropdown.js b/_site/javascripts/libs/bootstrap.dropdown.js new file mode 100755 index 0000000..43d7ae3 --- /dev/null +++ b/_site/javascripts/libs/bootstrap.dropdown.js @@ -0,0 +1,147 @@ +/* ======================================================================== + * Bootstrap: dropdown.js v3.1.1 + * http://getbootstrap.com/javascript/#dropdowns + * ======================================================================== + * Copyright 2011-2014 Twitter, Inc. + * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) + * ======================================================================== */ + + ++function ($) { + 'use strict'; + + // DROPDOWN CLASS DEFINITION + // ========================= + + var backdrop = '.dropdown-backdrop' + var toggle = '[data-toggle=dropdown]' + var Dropdown = function (element) { + $(element).on('click.bs.dropdown', this.toggle) + } + + Dropdown.prototype.toggle = function (e) { + var $this = $(this) + + if ($this.is('.disabled, :disabled')) return + + var $parent = getParent($this) + var isActive = $parent.hasClass('open') + + clearMenus() + + if (!isActive) { + if ('ontouchstart' in document.documentElement && !$parent.closest('.navbar-nav').length) { + // if mobile we use a backdrop because click events don't delegate + $('