Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base: master
...
compare: master
Checking mergeability… Don't worry, you can still create the pull request.
  • 15 commits
  • 5 files changed
  • 0 commit comments
  • 1 contributor
Commits on Mar 22, 2009
Austin Fonacier Adding body ul padding left:0px so it aligns better to the left wall fea33fb
Commits on Mar 29, 2009
Austin Fonacier the te_list more option shouldn't always take a ruby object, it can a…
…lso take a string
8a51dba
Austin Fonacier There were alot of missing features in tank_engine.js with _replace l…
…inks and lists. This should now work.
7100474
Austin Fonacier There were alot of missing features in tank_engine.js with _replace l…
…inks

and lists.  This should now work.
cd964cd
Austin Fonacier Merge branch 'master' of git@github.com:austinrfnd/tank-engine 23a4929
Commits on Apr 12, 2009
Austin Fonacier Let's use the jquery live instead of click so that if an ajax additio…
…n happens to the DOM, we always register the click
85ccd87
Commits on Apr 24, 2009
Austin Fonacier Adding documentation for the te_list element 24b0e9e
Austin Fonacier Oops forgort the as_replace parameter 3168f24
Austin Fonacier We are not guaranteed that the request has a format. I need to start …
…writing tests up in here.
2738111
Austin Fonacier Oops fixed a type in the tank engine.js f3a5571
Commits on Apr 26, 2009
Austin Fonacier Adding the ability of te_lists to take an array of link_in_lists. So …
…that a user can create a list that isn't an array of model objects
221586d
Commits on Apr 27, 2009
Austin Fonacier Adding te_link_to f4265d9
Austin Fonacier Hide the address bar f1db4b8
Austin Fonacier Getting rid of a duplicate TE javascript include since it is already …
…included in the helper
5685bdf
Commits on May 03, 2009
Austin Fonacier Getting rid of link_from_list. Being replaced from te_link_to c5266eb
View
41 assets/javascripts/tank_engine.js
@@ -1,8 +1,8 @@
function make_sliders() {
- $(".te_slide_left").click(function () {
+ $(".te_slide_left").live("click", function () {
return slide_left($(this).attr("href"));
});
- $(".te_slide_right").click(function() {
+ $(".te_slide_right").live("click", function() {
return slide_right($(this).attr("href"));
});
}
@@ -63,10 +63,47 @@ function make_toggles() {
function() {});
}
+// Let's listen to the click events of all the DOM events we care about
+function init_listiners() {
+ // Let's keep track of all the _replace
+ $("a[target='_replace']").live("click",
+ function(event){
+ // prevent link from actuall clicking
+ event.preventDefault();
+ var link_elememt = $(this);
+ //Make the link blue
+ $(link_elememt).attr("selected", "progress");
+
+ $.get($(this).attr('href'), function(data){
+ // Turn off the ajax loading gif
+ $(link_elememt).removeAttr('selected');
+ // Append the data
+ $(link_elememt).parent().parent().append(data);
+ // Remove the the selected
+ $(link_elememt).parent().remove();
+ // Attach the HTML
+ $(link_elememt).parent().html(data);
+ });
+ }
+ );
+}
+
+// Stolen from iui. We need to pre-load the preloader image
+function preloadImages()
+{
+ var preloader = document.createElement("div");
+ preloader.id = "preloader";
+ document.body.appendChild(preloader);
+}
function init() {
+ // Hide the address bar
+ // Uncomment on the line below if you don't want to hide the address bar.
+ scrollTo(0, 1);
make_sliders();
make_toggles();
+ init_listiners();
+ preloadImages();
}
$(function() {
View
1  assets/layouts/application.iphone.erb
@@ -10,7 +10,6 @@
<%= javascript_include_tag :defaults %>
<%= include_tank_engine_files %>
<%= yield :jquery %>
- <%= javascript_include_tag "tank_engine" %>
</head>
<body>
<div class="viewport_body">
View
3  assets/stylesheets/tank_engine.css
@@ -153,6 +153,9 @@ body[orient="landscape"] > .toolbar > h1 {
}
/************************************************************************************************/
+body ul{
+ padding-left: 0px;
+}
body ul > li {
position: relative;
View
2  lib/tank_engine_controller.rb
@@ -51,7 +51,7 @@ def set_iphone_format
end
def is_iphone_format?
- request.format.to_sym == self.class.iphone_request_format
+ request.format && request.format.to_sym == self.class.iphone_request_format
end
def is_iphone_request?
View
58 lib/tank_engine_helper.rb
@@ -46,22 +46,17 @@ def link_to_replace(name, options, html_options = {})
link_to(name, options, html_options)
end
+ # Use this to create a simple link_to that will slide.
+ def te_link_to(name, options, html_options ={}, slide = true)
+ html_options = apply_html_side(slide, html_options)
+ link_to(name, options, html_options)
+ end
+
def link_to_external(name, options, html_options = {})
html_options[:target] = "_self"
link_to(name, options, html_options)
end
- def link_from_list(name, options, slide = nil, html_options = {})
- if slide
- if html_options[:class]
- html_options[:class] += " te_slide_left"
- else
- html_options[:class] = "te_slide_left"
- end
- end
- link_to(name, options, html_options)
- end
-
def link_to_target(target, name, options, html_options = {})
if target == :replace
link_to_replace(name, options, html_options)
@@ -86,20 +81,40 @@ def link_to_target(target, name, options, html_options = {})
## Lists
def list_element(item, target = nil, slide = true)
- link = link_from_list(item.caption, item.url, slide)
+ link = te_link_to(item.caption, item.url, {}, slide)
content_tag(:li, link)
end
+
+ # This will create a an <li>URL</li> to be used in a te_list
+ def link_in_list(name, options, html_options = {}, slide = true )
+ html_options = apply_html_side(slide, html_options)
+ content_tag(:li, link_to(name, options, html_options))
+ end
def append_options(list_content, options = {})
list_content = options[:top] + list_content if options[:top]
- list_content += list_element(options[:more], :replace) if options[:more]
+ list_content += list_element(options[:more], :replace) if options[:more] && !options[:more].kind_of?(String)
+ list_content += content_tag(:li, options[:more]) if options[:more] && options[:more].kind_of?(String)
list_content += options[:bottom] if options[:bottom]
list_content
end
-
+
+ # <b>Items</b> array of an object that can respond to caption (url text) and target (url).
+ # Can also take an array of link_in_lists (URLs)
+ # <b>Options</b> Hash that can include:
+ # - top - ?
+ # - more - The more link on the bottom of the list that will replace the link with more list items
+ # - bottom - ?
+ # - as_replace - Boolean to display just the list elements with the surrounding uls
def te_list(items, options = {})
slide = !options[:no_slide]
- list_content = items.map {|i| list_element(i, nil, slide)}.join("\n")
+
+ if items && !items.empty? && items.first.kind_of?(String)
+ list_content = items.join("\n")
+ else
+ list_content = items.map {|i| list_element(i, nil, slide)}.join("\n")
+ end
+
list_content = append_options(list_content, options)
if options[:as_replace]
list_content
@@ -162,7 +177,18 @@ def observe_orientation_change(url_options = {})
def register_orientation_change
javascript_tag('$(function() { $("body").bind("orientationchange", updateOrientation) });')
end
-
+
+ private
+ def apply_html_side(slide, html_options)
+ if slide
+ if html_options[:class]
+ html_options[:class] += " te_slide_left"
+ else
+ html_options[:class] = "te_slide_left"
+ end
+ end
+ html_options
+ end
end
ActionView::Base.send(:include, TankEngineHelper)

No commit comments for this range

Something went wrong with that request. Please try again.