{I" class:ETI"ProcessedAsset; FI"logical_path; TI"cms/core_library.js; FI" pathname; TI"|/usr/local/rvm/gems/ruby-2.0.0-p481/bundler/gems/browsercms-a0b88590276e/app/assets/javascripts/cms/core_library.js.erb; FI"content_type; TI"application/javascript; TI" mtime; Tl+”%TI"length; TiI"digest; TI"%bfa0c6d106923dc65712094a8da2c8f8; FI"source; TI"// // Defines Core BrowserCMS functions used throughout the application. // // jQuery(function($) { //It would be cool if these were added to the real jQuery //You can call this a few ways: //createElement('p') => "
" //createElement('p','hi') => "hi
" //createElement('p', {align: 'center'}) => "" //createElement('p','hi',{align: 'center'}) => "hi
" $.createElement = function(tag_name, tag_value, tag_attrs) { var name = tag_name if (typeof tag_value == "object") { var value = null var attrs = tag_value } else { var value = tag_value var attrs = tag_attrs } var element = $(document.createElement(tag_name)) if (attrs) { $.each(attrs, function(k, v) { element.attr(k, v) }) } if (value) { element.html(value) } return element } var sanitizationRegexes = [ [/\s/, "_"], [/[&+()]/, "-"], [/[=?!'"{}\[\]#<>%]/, ""] ] $.cms = { // Return the CSRF token for any JS function that needs to do AJAX. // Since AJAX posts will fail if you don't attach this as defined here: // http://michaelhendrickx.com/201012_jquery-ajax-with-rails-authenticity-token.html csrfToken: function() { return $('meta[name=csrf-token]').attr('content'); }, sanitizeFileName: function(s) { var split = s.split(/\/|\\/) s = split[split.length - 1] $.each(sanitizationRegexes, function(i, e) { var r = new RegExp(e[0].source, 'g') s = s.replace(r, e[1]) }) return s; }, slug: function(s) { return $.trim(s.toLowerCase().replace(/[^a-zA-Z0-9_\s]+/g, '')).replace(/\ +/g, '-') }, showNotice: function(msg) { $('#message').removeClass('error').addClass('notice').html(msg).parent().show().animate({opacity: 1.0}, 3000).fadeOut("normal") }, showError: function(msg) { $('#message').removeClass('notice').addClass('error').html(msg).parent().show().animate({opacity: 1.0}, 3000).fadeOut("normal") }, attachEventHandlers: function(context) { $('a.button', context).click(function() { if ($(this).hasClass('disabled')) return false; }); $('a.http_post, a.http_put, a.http_delete', context).click(function() { if ($(this).hasClass('disabled')) return false; if ($(this).hasClass('confirm_with_title') ? confirm(this.title) : true) { // Create a hidden form to submit this link as PUT/POST/DELETE. var f = document.createElement('form') f.style.display = 'none' this.parentNode.appendChild(f) f.method = "POST" f.action = this.href $(f).attr('target', $(this).attr('target')) //Create the _method hidden input var m = document.createElement('input') var http_method = $(this).attr('class').match(/http_([^ ]*)/)[1] $(m).attr('type', 'hidden').attr('name', '_method').attr('value', http_method) f.appendChild(m) // Add the authenticity_token as a hidden input so rails doesn't reject the form. var m = document.createElement('input') $(m).attr('type', 'hidden').attr('name', 'authenticity_token').attr('value', $.cms.csrfToken()); f.appendChild(m); f.submit() } return false }) } } $.cms.attachEventHandlers(document); $('#message.notice').parent().show().animate({opacity: 1.0}, 3000).fadeOut("normal") $('#message.error').parent().show().animate({opacity: 1.0}, 3000).fadeOut("normal") }); // Autogenerate slugs for form fields as user types. // Requires two fields to enable autogeneration, a source and destination. You can leave one out for cases // where you don't want to overwrite the existing slug (i.e. editing an existing record's name). // // Required CSS classes: // .slug-source - The input field to pull the name from. // .slug-dest - The input field to set the slug value in. // @options data-prefix An optional prefix (on slug-dest) that should be added in front of autogenerated slugs // (i.e. ) jQuery(function($){ if ($('.slug-dest').length && $('.slug-source').length) { $('.slug-source').keyup(function() { var name = $('.slug-source').val(); if ($('.slug-dest').attr('data-prefix')) { var prefix = $('.slug-dest').data('prefix'); // Handle / section if (prefix !== '/') { prefix += "/"; } } else { var prefix = ""; } var slug_value = prefix + $.cms.slug(name); $('.slug-dest').val(slug_value); }); } }); // Automatically enable date_picker controls jQuery(function($){ if ($.datepicker) { $('input.date_picker').datepicker({ changeFirstDay: false, changeMonth: true, changeYear: true, closeText: '', showButtonPanel: true, dateFormat: 'yy/mm/dd' }); } }); // UI Enhancement to suggest paths for uploaded files jQuery(function($){ var path_input = $('.suggest_file_path'); if (path_input.length) { $('select[data-purpose=section_selector], input[data-purpose=cms_file_field]').change(function() { var section_id = $('select[data-purpose=section_selector]').val(); var section_path = $('.section_id_map[data-id=' + section_id + ']').data('path'); var file_path = $.cms.sanitizeFileName($('input[data-purpose=cms_file_field]').val()); path_input.val(section_path + file_path); }); } }); //CookieSet allows us to treat one cookie value as a Set of values (Each value can appear only once) jQuery(function($) { var sep = '|' $.cookieSet = { //Treats the cookie as an array add: function(name, value, options) { this.remove(name, value, options) var set = this.get(name) if (set) { set.push(value) } else { var set = [value] } $.cookie(name, set.join(sep), options) return this.get(name) }, get: function(name) { var val = $.cookie(name) if (val) { return val.split(sep) } else { return null } }, remove: function(name, value, options) { var set = this.get(name) if (set) { var arr = [] $.each(set, function() { if (this != value + '') { arr.push(this) } }) $.cookie(name, arr.join(sep), options) return this.get(name) } else { return null } }, //Treats the cookie as an array contains: function(name, value) { var set = this.get(name) if (set) { return $.inArray(value + '', set) > -1 } else { return false } } } }); ; TI"dependency_digest; TI"%2192bd97e1d4732029fcba3ff2da6a2b; FI"required_paths; T[I"|/usr/local/rvm/gems/ruby-2.0.0-p481/bundler/gems/browsercms-a0b88590276e/app/assets/javascripts/cms/core_library.js.erb; FI"dependency_paths; T[{I" path; TI"|/usr/local/rvm/gems/ruby-2.0.0-p481/bundler/gems/browsercms-a0b88590276e/app/assets/javascripts/cms/core_library.js.erb; FI" mtime; TI"2014-09-11T18:43:32-04:00; TI"digest; TI"%1f21ca2b02918cae267ba8e04f0ec824; FI" _version; TI"%5ef14a844324cba3e114bd0123f88a5e; F