Skip to content

Commit

Permalink
interface to coffee
Browse files Browse the repository at this point in the history
  • Loading branch information
gogogarrett committed Sep 20, 2011
1 parent 9f37f0d commit 3221ab5
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 90 deletions.
2 changes: 1 addition & 1 deletion Gemfile.lock
Expand Up @@ -31,7 +31,7 @@ PATH
friendly_id_globalize3 (~> 3.2.1)
globalize3 (~> 0.2.0.beta3)
jquery-rails
rails (>= 3.1.0)
rails (>= 3.1.1.rc1)
refinerycms-base (= 2.0.0)
refinerycms-settings (= 2.0.0)
sass-rails (~> 3.1.0)
Expand Down
89 changes: 0 additions & 89 deletions core/app/assets/javascripts/refinery/admin.js
Expand Up @@ -83,95 +83,6 @@ init_ajaxy_pagination = function(){
}
}

init_interface = function() {
if (parent && parent.document.location.href != document.location.href) {
$('body#dialog_container.dialog').addClass('iframed');
}
$('input:submit:not(.button)').addClass('button');

if (!$.browser.msie) {
$('#page_container, .wym_box').corner('5px bottom');
$('.wym_box').corner('5px tr');
$('.field > .wym_box').corner('5px tl');
$('.wym_iframe iframe').corner('2px');
$('.form-actions:not(".form-actions-dialog")').corner('5px');
}
$('#recent_activity li a, #recent_inquiries li a').each(function(i, a) {
$(this).textTruncate({
width: $(this).width()
, tooltip: false
});
});

// make sure that users can tab to wymeditor fields and add an overlay while loading.
$('textarea.wymeditor').each(function() {
textarea = $(this);
if ((instance = WYMeditor.INSTANCES[$((textarea.next('.wym_box').find('iframe').attr('id')||'').split('_')).last().get(0)]) != null) {
if ((next = textarea.parent().next()) != null && next.length > 0) {
next.find('input, textarea').keydown($.proxy(function(e) {
shiftHeld = e.shiftKey;
if (shiftHeld && e.keyCode == $.ui.keyCode.TAB) {
this._iframe.contentWindow.focus();
e.preventDefault();
}
}, instance)).keyup(function(e) {
shiftHeld = false;
});
}
if ((prev = textarea.parent().prev()) != null && prev.length > 0) {
prev.find('input, textarea').keydown($.proxy(function(e) {
if (e.keyCode == $.ui.keyCode.TAB) {
this._iframe.contentWindow.focus();
e.preventDefault();
}
}, instance));
}
}
});

// ensure that the menu isn't wider than the page_container or else it looks silly to round that corner.
if (($menu = $('#menu')).length > 0) {
$menu.jcarousel({
vertical: false
, scroll: 1
, buttonNextHTML: "<img src='/assets/refinery/carousel-right.png' alt='down' height='15' width='10' />"
, buttonPrevHTML: "<img src='/assets/refinery/carousel-left.png' alt='up' height='15' width='10' />"
, listTag: $menu.get(0).tagName.toLowerCase()
, itemTag: $menu.children(':first').get(0).tagName.toLowerCase()
});

if ($menu.outerWidth() < $('#page_container').outerWidth()) {
$("#page_container:not('.login #page_container')").corner('5px tr');
} else {
$("#page_container:not('.login #page_container')").uncorner();
}
}

$('#current_locale li a').click(function(e) {
$('#current_locale li a span').each(function(span){
$(this).css('display', $(this).css('display') == 'none' ? '' : 'none');
});
$('#other_locales').animate({opacity: 'toggle', height: 'toggle'}, 250);
$('html,body').animate({
scrollTop: $('#other_locales').parent().offset().top
}, 250);
e.preventDefault();
});

$('#existing_image img').load(function(){
$('form.edit_image .form-actions').css({
'margin-top': ($('#existing_image').height() - $('form.edit_image').height() + 8)
});
});

$('.form-actions .form-actions-left input:submit#submit_button').click(function(e) {
$("<img src='/assets/refinery/ajax-loader.gif' width='16' height='16' class='save-loader' />").appendTo($(this).parent());
});

$('a.suppress').live('click', function(e){
e.preventDefault();
});
};

init_modal_dialogs = function(){
$('a[href*="dialog=true"]').not('#dialog_container a').each(function(i, anchor) {
Expand Down
64 changes: 64 additions & 0 deletions core/app/assets/javascripts/refinery/interface.js.coffee
@@ -0,0 +1,64 @@
@init_interface = ->
$("body#dialog_container.dialog").addClass "iframed" if parent and parent.document.location.href != document.location.href
$("input:submit:not(.button)").addClass "button"
unless $.browser.msie
$("#page_container, .wym_box").corner "5px bottom"
$(".wym_box").corner "5px tr"
$(".field > .wym_box").corner "5px tl"
$(".wym_iframe iframe").corner "2px"
$(".form-actions:not(\".form-actions-dialog\")").corner "5px"
$("#recent_activity li a, #recent_inquiries li a").each (i, a) ->
$(this).textTruncate
width: $(this).width()
tooltip: false

$("textarea.wymeditor").each ->
textarea = $(this)
if (instance = WYMeditor.INSTANCES[$((textarea.next(".wym_box").find("iframe").attr("id") or "").split("_")).last().get(0)])?
if (next = textarea.parent().next())? and next.length > 0
next.find("input, textarea").keydown($.proxy((e) ->
shiftHeld = e.shiftKey
if shiftHeld and e.keyCode == $.ui.keyCode.TAB
@_iframe.contentWindow.focus()
e.preventDefault()
, instance)).keyup (e) ->
shiftHeld = false
if (prev = textarea.parent().prev())? and prev.length > 0
prev.find("input, textarea").keydown $.proxy((e) ->
if e.keyCode == $.ui.keyCode.TAB
@_iframe.contentWindow.focus()
e.preventDefault()
, instance)

if ($menu = $("#menu")).length > 0
$menu.jcarousel
vertical: false
scroll: 1
buttonNextHTML: "<img src='/assets/refinery/carousel-right.png' alt='down' height='15' width='10' />"
buttonPrevHTML: "<img src='/assets/refinery/carousel-left.png' alt='up' height='15' width='10' />"
listTag: $menu.get(0).tagName.toLowerCase()
itemTag: $menu.children(":first").get(0).tagName.toLowerCase()

if $menu.outerWidth() < $("#page_container").outerWidth()
$("#page_container:not('.login #page_container')").corner "5px tr"
else
$("#page_container:not('.login #page_container')").uncorner()
$("#current_locale li a").click (e) ->
$("#current_locale li a span").each (span) ->
$(this).css "display", (if $(this).css("display") == "none" then "" else "none")

$("#other_locales").animate
opacity: "toggle"
height: "toggle"
, 250
$("html,body").animate scrollTop: $("#other_locales").parent().offset().top, 250
e.preventDefault()

$("#existing_image img").load ->
$("form.edit_image .form-actions").css "margin-top": ($("#existing_image").height() - $("form.edit_image").height() + 8)

$(".form-actions .form-actions-left input:submit#submit_button").click (e) ->
$("<img src='/assets/refinery/ajax-loader.gif' width='16' height='16' class='save-loader' />").appendTo $(this).parent()

$("a.suppress").live "click", (e) ->
e.preventDefault()
1 change: 1 addition & 0 deletions core/app/assets/javascripts/refinery/refinery.js
Expand Up @@ -14,4 +14,5 @@
*= require ./site_bar
*= require ./admin
*= require ./submenu
*= require ./interface
*/

0 comments on commit 3221ab5

Please sign in to comment.