Provides a set of helper methods for jquery-mobile buttons
Alert Button Link
alert_button_link 'alert', new_post_path # => <a data-role="button" data-icon="alert" href="/posts/new">alert</a> alert_button_link 'alert', new_post_path, {'data-theme' => 'c', 'data-iconpos' => 'right'} # => <a data-role="button" data-icon="alert" data-iconpos="right" data-theme="c" href="/posts/new">alert</a>
# File lib/jqmobile_helpers/buttons_helper.rb, line 454 454: def alert_button_link(name, link, options = {}) 455: 456: html_options = options.stringify_keys! 457: default_options = {'data-role' => "button", 'data-icon' => "alert"} 458: 459: if html_options.has_key?('data-theme') 460: default_options = default_options.merge({'data-theme' => html_options['data-theme']}) 461: end 462: 463: if html_options.has_key?('data-iconpos') 464: default_options = default_options.merge({'data-iconpos' => html_options['data-iconpos']}) 465: end 466: 467: if html_options.has_key?('data-inline') 468: default_options = default_options.merge({'data-inline' => html_options['data-inline']}) 469: end 470: 471: content_tag(:a, name, {:href => link}.merge(default_options)) 472: end
Back Button Link
back_button_link 'back', new_post_path # => <a data-role="button" data-icon="back" href="/posts/new">back</a> back_button_link 'back', new_post_path, {'data-theme' => 'c', 'data-iconpos' => 'right'} # => <a data-role="button" data-icon="back" data-iconpos="right" data-theme="c" href="/posts/new">back</a>
# File lib/jqmobile_helpers/buttons_helper.rb, line 367 367: def back_button_link(name, link, options = {}) 368: 369: html_options = options.stringify_keys! 370: default_options = {'data-role' => "button", 'data-icon' => "back"} 371: 372: if html_options.has_key?('data-theme') 373: default_options = default_options.merge({'data-theme' => html_options['data-theme']}) 374: end 375: 376: if html_options.has_key?('data-iconpos') 377: default_options = default_options.merge({'data-iconpos' => html_options['data-iconpos']}) 378: end 379: 380: if html_options.has_key?('data-inline') 381: default_options = default_options.merge({'data-inline' => html_options['data-inline']}) 382: end 383: 384: content_tag(:a, name, {:href => link}.merge(default_options)) 385: end
In cases where there is more than one possible action per list item, a split button can be used to offer two independently clickable items — the list item and a small arrow icon in the far right The framework will add a vertical divider line and sets the title attribute of the link to the text the link for accessibility. It is similar for the Split-Button List.
# => 'data-inset' => 'true' (Default data-inset is set to true) # => 'data-theme' => 'c' (Default data-theme is set to c)
<%= back_split_button "Back", posts_path %> # => <div data-role="content"><a href="index.html" data-role="button" data-rel="back">Back</a></div>
# File lib/jqmobile_helpers/buttons_helper.rb, line 579 579: def back_split_button(name, link, options ={} ) 580: html_options = options.stringify_keys! 581: default_options = {'data-role' => "button", 'data-rel' => "back"} 582: content_tag(:a, name, {:href => link}.merge(default_options)) 583: end
Button Link
button_link 'New Post', new_post_path # => <a data-role="button" href="http://google.com">New Post</a> button_link 'New Post', new_post_path, {'data-theme' => 'c', 'data-icon' => 'plus', 'data-iconpos' => 'right'} # => <a data-icon="plus" data-iconpos="right" data-role="button" data-theme="c" href="http://google.com">New Post</a>
# File lib/jqmobile_helpers/buttons_helper.rb, line 15 15: def button_link(name, link, options = {}) 16: 17: html_options = options.stringify_keys! 18: default_options = {'data-role' => "button"} 19: 20: if html_options.has_key?('data-icon') 21: default_options = default_options.merge({'data-icon' => html_options['data-icon']}) 22: end 23: 24: if html_options.has_key?('data-theme') 25: default_options = default_options.merge({'data-theme' => html_options['data-theme']}) 26: end 27: 28: if html_options.has_key?('data-iconpos') 29: default_options = default_options.merge({'data-iconpos' => html_options['data-iconpos']}) 30: end 31: 32: if html_options.has_key?('data-inline') 33: default_options = default_options.merge({'data-inline' => html_options['data-inline']}) 34: end 35: 36: content_tag(:a, name, {:href => link}.merge(default_options)) 37: end
Check Button Link
check_button_link 'check', new_post_path # => <a data-role="button" data-icon="check" href="/posts/new">check</a> check_button_link 'check', new_post_path, {'data-theme' => 'c', 'data-iconpos' => 'right'} # => <a data-role="button" data-icon="check" data-iconpos="right" data-theme="c" href="/posts/new">check</a>
# File lib/jqmobile_helpers/buttons_helper.rb, line 251 251: def check_button_link(name, link, options = {}) 252: 253: html_options = options.stringify_keys! 254: default_options = {'data-role' => "button", 'data-icon' => "check"} 255: 256: if html_options.has_key?('data-theme') 257: default_options = default_options.merge({'data-theme' => html_options['data-theme']}) 258: end 259: 260: if html_options.has_key?('data-iconpos') 261: default_options = default_options.merge({'data-iconpos' => html_options['data-iconpos']}) 262: end 263: 264: if html_options.has_key?('data-inline') 265: default_options = default_options.merge({'data-inline' => html_options['data-inline']}) 266: end 267: 268: content_tag(:a, name, {:href => link}.merge(default_options)) 269: end
Delete Button Link
delete_button_link 'Delete', destroy_path # => <a data-role="button" data-icon="delete" href="/posts/new">Delete</a> delete_button_link 'Delete', destroy_path, {'data-theme' => 'c', 'data-iconpos' => 'right'} # => <a data-role="button" data-icon="delete" data-iconpos="right" data-theme="c" href="/posts/destroy">Delete</a>
# File lib/jqmobile_helpers/buttons_helper.rb, line 48 48: def delete_button_link(name, link, options = {}) 49: 50: html_options = options.stringify_keys! 51: default_options = {'data-role' => "button", 'data-icon' => "delete"} 52: 53: if html_options.has_key?('data-theme') 54: default_options = default_options.merge({'data-theme' => html_options['data-theme']}) 55: end 56: 57: if html_options.has_key?('data-iconpos') 58: default_options = default_options.merge({'data-iconpos' => html_options['data-iconpos']}) 59: end 60: 61: if html_options.has_key?('data-inline') 62: default_options = default_options.merge({'data-inline' => html_options['data-inline']}) 63: end 64: 65: content_tag(:a, name, {:href => link}.merge(default_options)) 66: end
Down Button Link
down_button_link 'bottom', new_post_path # => <a data-role="button" data-icon="arrow-d" href="/posts/new">bottom</a> down_button_link 'bottom', new_post_path, {'data-theme' => 'c', 'data-iconpos' => 'bottom'} # => <a data-role="button" data-icon="arrow-d" data-iconpos="bottom" data-theme="c" href="/posts/new">bottom</a>
# File lib/jqmobile_helpers/buttons_helper.rb, line 164 164: def down_button_link(name, link, options = {}) 165: 166: html_options = options.stringify_keys! 167: default_options = {'data-role' => "button", 'data-icon' => "arrow-d"} 168: 169: if html_options.has_key?('data-theme') 170: default_options = default_options.merge({'data-theme' => html_options['data-theme']}) 171: end 172: 173: if html_options.has_key?('data-iconpos') 174: default_options = default_options.merge({'data-iconpos' => html_options['data-iconpos']}) 175: end 176: 177: if html_options.has_key?('data-inline') 178: default_options = default_options.merge({'data-inline' => html_options['data-inline']}) 179: end 180: 181: content_tag(:a, name, {:href => link}.merge(default_options)) 182: end
Forward Button Link
forward_button_link 'forward', new_post_path # => <a data-role="button" data-icon="forward" href="/posts/new">forward</a> forward_button_link 'forward', new_post_path, {'data-theme' => 'c', 'data-iconpos' => 'right'} # => <a data-role="button" data-icon="forward" data-iconpos="right" data-theme="c" href="/posts/new">forward</a>
# File lib/jqmobile_helpers/buttons_helper.rb, line 338 338: def forward_button_link(name, link, options = {}) 339: 340: html_options = options.stringify_keys! 341: default_options = {'data-role' => "button", 'data-icon' => "forward"} 342: 343: if html_options.has_key?('data-theme') 344: default_options = default_options.merge({'data-theme' => html_options['data-theme']}) 345: end 346: 347: if html_options.has_key?('data-iconpos') 348: default_options = default_options.merge({'data-iconpos' => html_options['data-iconpos']}) 349: end 350: 351: if html_options.has_key?('data-inline') 352: default_options = default_options.merge({'data-inline' => html_options['data-inline']}) 353: end 354: 355: content_tag(:a, name, {:href => link}.merge(default_options)) 356: end
Gear Button Link
gear_button_link 'gear', new_post_path # => <a data-role="button" data-icon="gear" href="/posts/new">gear</a> gear_button_link 'gear', new_post_path, {'data-theme' => 'c', 'data-iconpos' => 'right'} # => <a data-role="button" data-icon="gear" data-iconpos="right" data-theme="c" href="/posts/new">gear</a>
# File lib/jqmobile_helpers/buttons_helper.rb, line 280 280: def gear_button_link(name, link, options = {}) 281: 282: html_options = options.stringify_keys! 283: default_options = {'data-role' => "button", 'data-icon' => "gear"} 284: 285: if html_options.has_key?('data-theme') 286: default_options = default_options.merge({'data-theme' => html_options['data-theme']}) 287: end 288: 289: if html_options.has_key?('data-iconpos') 290: default_options = default_options.merge({'data-iconpos' => html_options['data-iconpos']}) 291: end 292: 293: if html_options.has_key?('data-inline') 294: default_options = default_options.merge({'data-inline' => html_options['data-inline']}) 295: end 296: 297: content_tag(:a, name, {:href => link}.merge(default_options)) 298: end
Grid Button Link
grid_button_link 'grid', new_post_path # => <a data-role="button" data-icon="grid" href="/posts/new">grid</a> grid_button_link 'grid', new_post_path, {'data-theme' => 'c', 'data-iconpos' => 'right'} # => <a data-role="button" data-icon="grid" data-iconpos="right" data-theme="c" href="/posts/new">grid</a>
# File lib/jqmobile_helpers/buttons_helper.rb, line 396 396: def grid_button_link(name, link, options = {}) 397: 398: html_options = options.stringify_keys! 399: default_options = {'data-role' => "button", 'data-icon' => "grid"} 400: 401: if html_options.has_key?('data-theme') 402: default_options = default_options.merge({'data-theme' => html_options['data-theme']}) 403: end 404: 405: if html_options.has_key?('data-iconpos') 406: default_options = default_options.merge({'data-iconpos' => html_options['data-iconpos']}) 407: end 408: 409: if html_options.has_key?('data-inline') 410: default_options = default_options.merge({'data-inline' => html_options['data-inline']}) 411: end 412: 413: content_tag(:a, name, {:href => link}.merge(default_options)) 414: end
Grouped Button
group_button(" #{home_button_link('home', buttons_path, 'data-iconpos' => 'right')} #{refresh_button_link 'refresh', buttons_path} ") # => <div data-role="controlgroup"> <a data-icon="home" data-iconpos="right" data-role="button" href="/buttons">home</a> <a data-icon="refresh" data-role="button" href="/buttons">refresh</a> </div> group_button(" #{home_button_link('home', buttons_path, 'data-iconpos' => 'right')} #{refresh_button_link 'refresh', buttons_path}, {'data-type' => 'horizontal'} ") # => <div data-role="controlgroup" data-type="horizontal" > <a data-icon="home" data-iconpos="right" data-role="button" href="/buttons">home</a> <a data-icon="refresh" data-role="button" href="/buttons">refresh</a> </div>
# File lib/jqmobile_helpers/buttons_helper.rb, line 605 605: def group_button(content, options = {}) 606: 607: html_options = options.stringify_keys! 608: default_options = {'data-role'=> "controlgroup"} 609: 610: if html_options.has_key?('data-type') 611: default_options = default_options.merge({'data-type' => html_options['data-type']}) 612: end 613: 614: content_tag(:div, content, default_options, false) 615: end
Home Button Link
home_button_link 'home', new_post_path # => <a data-role="button" data-icon="home" href="/posts/new">home</a> home_button_link 'home', new_post_path, {'data-theme' => 'c', 'data-iconpos' => 'right'} # => <a data-role="button" data-icon="home" data-iconpos="right" data-theme="c" href="/posts/new">home</a>
# File lib/jqmobile_helpers/buttons_helper.rb, line 512 512: def home_button_link(name, link, options = {}) 513: 514: html_options = options.stringify_keys! 515: default_options = {'data-role' => "button", 'data-icon' => "home"} 516: 517: if html_options.has_key?('data-theme') 518: default_options = default_options.merge({'data-theme' => html_options['data-theme']}) 519: end 520: 521: if html_options.has_key?('data-iconpos') 522: default_options = default_options.merge({'data-iconpos' => html_options['data-iconpos']}) 523: end 524: 525: if html_options.has_key?('data-inline') 526: default_options = default_options.merge({'data-inline' => html_options['data-inline']}) 527: end 528: 529: content_tag(:a, name, {:href => link}.merge(default_options)) 530: end
Info Button Link
info_button_link 'info', new_post_path # => <a data-role="button" data-icon="info" href="/posts/new">info</a> info_button_link 'info', new_post_path, {'data-theme' => 'c', 'data-iconpos' => 'right'} # => <a data-role="button" data-icon="info" data-iconpos="right" data-theme="c" href="/posts/new">info</a>
# File lib/jqmobile_helpers/buttons_helper.rb, line 483 483: def info_button_link(name, link, options = {}) 484: 485: html_options = options.stringify_keys! 486: default_options = {'data-role' => "button", 'data-icon' => "info"} 487: 488: if html_options.has_key?('data-theme') 489: default_options = default_options.merge({'data-theme' => html_options['data-theme']}) 490: end 491: 492: if html_options.has_key?('data-iconpos') 493: default_options = default_options.merge({'data-iconpos' => html_options['data-iconpos']}) 494: end 495: 496: if html_options.has_key?('data-inline') 497: default_options = default_options.merge({'data-inline' => html_options['data-inline']}) 498: end 499: 500: content_tag(:a, name, {:href => link}.merge(default_options)) 501: end
Inline Buttons
inline_button(" #{home_button_link('home', buttons_path, 'data-iconpos' => 'right')} #{refresh_button_link 'refresh', buttons_path} ") # => <div data-inline="true" data-role="controlgroup" data-type="horizontal"> <a data-icon="home" data-iconpos="right" data-role="button" href="/buttons">home</a> <a data-icon="refresh" data-role="button" href="/buttons">refresh</a> </div>
# File lib/jqmobile_helpers/buttons_helper.rb, line 630 630: def inline_button(content) 631: 632: default_options = {'data-inline'=> "true", 'data-role'=> "controlgroup", 'data-type' => "horizontal"} 633: 634: content_tag(:div, content, default_options, false) 635: end
Left Button Link
left_button_link 'Back', new_post_path # => <a data-role="button" data-icon="arrow-l" href="/posts/new">Back</a> left_button_link 'Back', new_post_path, {'data-theme' => 'c', 'data-iconpos' => 'right'} # => <a data-role="button" data-icon="arrow-l" data-iconpos="right" data-theme="c" href="/posts/new">Back</a>
# File lib/jqmobile_helpers/buttons_helper.rb, line 77 77: def left_button_link(name, link, options = {}) 78: 79: html_options = options.stringify_keys! 80: default_options = {'data-role' => "button", 'data-icon' => "arrow-l"} 81: 82: if html_options.has_key?('data-theme') 83: default_options = default_options.merge({'data-theme' => html_options['data-theme']}) 84: end 85: 86: if html_options.has_key?('data-iconpos') 87: default_options = default_options.merge({'data-iconpos' => html_options['data-iconpos']}) 88: end 89: 90: if html_options.has_key?('data-inline') 91: default_options = default_options.merge({'data-inline' => html_options['data-inline']}) 92: end 93: 94: content_tag(:a, name, {:href => link}.merge(default_options)) 95: end
Minus Button Link
minus_button_link 'minus', new_post_path # => <a data-role="button" data-icon="minus" href="/posts/new">minus</a> minus_button_link 'minus', new_post_path, {'data-theme' => 'c', 'data-iconpos' => 'right'} # => <a data-role="button" data-icon="minus" data-iconpos="right" data-theme="c" href="/posts/new">minus</a>
# File lib/jqmobile_helpers/buttons_helper.rb, line 222 222: def minus_button_link(name, link, options = {}) 223: 224: html_options = options.stringify_keys! 225: default_options = {'data-role' => "button", 'data-icon' => "minus"} 226: 227: if html_options.has_key?('data-theme') 228: default_options = default_options.merge({'data-theme' => html_options['data-theme']}) 229: end 230: 231: if html_options.has_key?('data-iconpos') 232: default_options = default_options.merge({'data-iconpos' => html_options['data-iconpos']}) 233: end 234: 235: if html_options.has_key?('data-inline') 236: default_options = default_options.merge({'data-inline' => html_options['data-inline']}) 237: end 238: 239: content_tag(:a, name, {:href => link}.merge(default_options)) 240: end
Plus Button Link
plus_button_link 'plus', new_post_path # => <a data-role="button" data-icon="plus" href="/posts/new">plus</a> plus_button_link 'plus', new_post_path, {'data-theme' => 'c', 'data-iconpos' => 'right'} # => <a data-role="button" data-icon="plus" data-iconpos="right" data-theme="c" href="/posts/new">plus</a>
# File lib/jqmobile_helpers/buttons_helper.rb, line 193 193: def plus_button_link(name, link, options = {}) 194: 195: html_options = options.stringify_keys! 196: default_options = {'data-role' => "button", 'data-icon' => "plus"} 197: 198: if html_options.has_key?('data-theme') 199: default_options = default_options.merge({'data-theme' => html_options['data-theme']}) 200: end 201: 202: if html_options.has_key?('data-iconpos') 203: default_options = default_options.merge({'data-iconpos' => html_options['data-iconpos']}) 204: end 205: 206: if html_options.has_key?('data-inline') 207: default_options = default_options.merge({'data-inline' => html_options['data-inline']}) 208: end 209: 210: content_tag(:a, name, {:href => link}.merge(default_options)) 211: end
Refresh Button Link
refresh_button_link 'refresh', new_post_path # => <a data-role="button" data-icon="refresh" href="/posts/new">refresh</a> refresh_button_link 'refresh', new_post_path, {'data-theme' => 'c', 'data-iconpos' => 'right'} # => <a data-role="button" data-icon="refresh" data-iconpos="right" data-theme="c" href="/posts/new">refresh</a>
# File lib/jqmobile_helpers/buttons_helper.rb, line 309 309: def refresh_button_link(name, link, options = {}) 310: 311: html_options = options.stringify_keys! 312: default_options = {'data-role' => "button", 'data-icon' => "refresh"} 313: 314: if html_options.has_key?('data-theme') 315: default_options = default_options.merge({'data-theme' => html_options['data-theme']}) 316: end 317: 318: if html_options.has_key?('data-iconpos') 319: default_options = default_options.merge({'data-iconpos' => html_options['data-iconpos']}) 320: end 321: 322: if html_options.has_key?('data-inline') 323: default_options = default_options.merge({'data-inline' => html_options['data-inline']}) 324: end 325: 326: content_tag(:a, name, {:href => link}.merge(default_options)) 327: end
Right Button Link
right_button_link 'Proceed', new_post_path # => <a data-role="button" data-icon="arrow-r" href="/posts/new" data-theme="c">Proceed</a> right_button_link 'Proceed', new_post_path, {'data-theme' => 'c', 'data-iconpos' => 'right'} # => <a data-role="button" data-icon="arrow-r" data-iconpos="right" data-theme="c" href="/posts/new">Proceed</a>
# File lib/jqmobile_helpers/buttons_helper.rb, line 106 106: def right_button_link(name, link, options = {}) 107: 108: html_options = options.stringify_keys! 109: default_options = {'data-role' => "button", 'data-icon' => "arrow-r"} 110: 111: if html_options.has_key?('data-theme') 112: default_options = default_options.merge({'data-theme' => html_options['data-theme']}) 113: end 114: 115: if html_options.has_key?('data-iconpos') 116: default_options = default_options.merge({'data-iconpos' => html_options['data-iconpos']}) 117: end 118: 119: if html_options.has_key?('data-inline') 120: default_options = default_options.merge({'data-inline' => html_options['data-inline']}) 121: end 122: 123: content_tag(:a, name, {:href => link}.merge(default_options)) 124: end
Search Button Link
search_button_link 'search', new_post_path # => <a data-role="button" data-icon="search" href="/posts/new">search</a> search_button_link 'search', new_post_path, {'data-theme' => 'c', 'data-iconpos' => 'right'} # => <a data-role="button" data-icon="search" data-iconpos="right" data-theme="c" href="/posts/new">search</a>
# File lib/jqmobile_helpers/buttons_helper.rb, line 541 541: def search_button_link(name, link, options = {}) 542: 543: html_options = options.stringify_keys! 544: default_options = {'data-role' => "button", 'data-icon' => "search"} 545: 546: if html_options.has_key?('data-theme') 547: default_options = default_options.merge({'data-theme' => html_options['data-theme']}) 548: end 549: 550: if html_options.has_key?('data-iconpos') 551: default_options = default_options.merge({'data-iconpos' => html_options['data-iconpos']}) 552: end 553: 554: if html_options.has_key?('data-inline') 555: default_options = default_options.merge({'data-inline' => html_options['data-inline']}) 556: end 557: 558: content_tag(:a, name, {:href => link}.merge(default_options)) 559: end
Star Button Link
star_button_link 'star', new_post_path # => <a data-role="button" data-icon="star" href="/posts/new">star</a> star_button_link 'star', new_post_path, {'data-theme' => 'c', 'data-iconpos' => 'right'} # => <a data-role="button" data-icon="star" data-iconpos="right" data-theme="c" href="/posts/new">star</a>
# File lib/jqmobile_helpers/buttons_helper.rb, line 425 425: def star_button_link(name, link, options = {}) 426: 427: html_options = options.stringify_keys! 428: default_options = {'data-role' => "button", 'data-icon' => "star"} 429: 430: if html_options.has_key?('data-theme') 431: default_options = default_options.merge({'data-theme' => html_options['data-theme']}) 432: end 433: 434: if html_options.has_key?('data-iconpos') 435: default_options = default_options.merge({'data-iconpos' => html_options['data-iconpos']}) 436: end 437: 438: if html_options.has_key?('data-inline') 439: default_options = default_options.merge({'data-inline' => html_options['data-inline']}) 440: end 441: 442: content_tag(:a, name, {:href => link}.merge(default_options)) 443: end
Up Button Link
up_button_link 'top', new_post_path # => <a data-role="button" data-icon="arrow-u" href="/posts/new">top</a> up_button_link 'top', new_post_path, {'data-theme' => 'c', 'data-iconpos' => 'top'} # => <a data-role="button" data-icon="arrow-u" data-iconpos="top" data-theme="c" href="/posts/new">top</a>
# File lib/jqmobile_helpers/buttons_helper.rb, line 135 135: def up_button_link(name, link, options = {}) 136: 137: html_options = options.stringify_keys! 138: default_options = {'data-role' => "button", 'data-icon' => "arrow-u"} 139: 140: if html_options.has_key?('data-theme') 141: default_options = default_options.merge({'data-theme' => html_options['data-theme']}) 142: end 143: 144: if html_options.has_key?('data-iconpos') 145: default_options = default_options.merge({'data-iconpos' => html_options['data-iconpos']}) 146: end 147: 148: if html_options.has_key?('data-inline') 149: default_options = default_options.merge({'data-inline' => html_options['data-inline']}) 150: end 151: 152: content_tag(:a, name, {:href => link}.merge(default_options)) 153: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.