Permalink
Browse files

Merge remote-tracking branch 'origin/3.0'

  • Loading branch information...
2 parents e51937f + 47b56d4 commit 4cc82e906bf9e4f2a94a100684b8d9767c05d232 @chillu chillu committed Aug 20, 2012
@@ -296,9 +296,9 @@ function init() {
);
// TODO Confuses jQuery.ondemand through document.write()
- // if (Director::isDev()) {
- // Requirements::javascript(THIRDPARTY_DIR . '/jquery-entwine/src/jquery.entwine.inspector.js');
- // }
+ if (Director::isDev()) {
+ Requirements::javascript(THIRDPARTY_DIR . '/jquery-entwine/src/jquery.entwine.inspector.js');
+ }
Requirements::css(FRAMEWORK_ADMIN_DIR . '/thirdparty/jquery-notice/jquery.notice.css');
Requirements::css(THIRDPARTY_DIR . '/jquery-ui-themes/smoothness/jquery-ui.css');
@@ -20,29 +20,51 @@ jQuery.noConflict();
// apply an select element only when it is ready, ie. when it is rendered into a template
// with css applied and got a width value.
- var applyChosen = function(el){
- if(el.outerWidth()){
- el.chosen({
- 'disable_search_threshold' : 20,
- 'allow_single_deselect': true
- }).addClass("has-chzn");
- // Copy over title attribute if required
- if(el.attr('title')) el.siblings('.chzn-container').attr('title', el.attr('title'));
+ var applyChosen = function(el) {
+ if(el.is(':visible')) {
+ el.addClass('has-chzn').chosen({
+ allow_single_deselect: true,
+ disable_search_threshold: 20
+ });
+
+ var title = el.prop('title')
+
+ if(title) {
+ el.siblings('.chzn-container').prop('title', title);
+ }
} else {
- setTimeout(function() {applyChosen(el);},500);
+ setTimeout(function() { applyChosen(el); }, 500);
}
};
+
+ /**
+ * Compare URLs, but normalize trailing slashes in
+ * URL to work around routing weirdnesses in SS_HTTPRequest.
+ * Also normalizes relative URLs by prefixing them with the <base>.
+ */
+ var isSameUrl = function(url1, url2) {
+ var baseUrl = $('base').attr('href');
+ url1 = $.path.isAbsoluteUrl(url1) ? url1 : $.path.makeUrlAbsolute(url1, baseUrl),
+ url2 = $.path.isAbsoluteUrl(url2) ? url2 : $.path.makeUrlAbsolute(url2, baseUrl);
+ var url1parts = $.path.parseUrl(url1), url2parts = $.path.parseUrl(url2);
+ return (
+ url1parts.pathname.replace(/\/*$/, '') == url2parts.pathname.replace(/\/*$/, '') &&
+ url1parts.search == url2parts.search
+ );
+ };
$(window).bind('resize', positionLoadingSpinner).trigger('resize');
// global ajax handlers
$(document).ajaxComplete(function(e, xhr, settings) {
// Simulates a redirect on an ajax response.
if(window.History.enabled) {
- var url = xhr.getResponseHeader('X-ControllerURL'), opts, requestHeaders = settings.headers;
- // Normalize trailing slashes in URL to work around routing weirdnesses in SS_HTTPRequest.
- var isSame = (url && History.getPageUrl().replace(/\/+$/, '') == url.replace(/\/+$/, ''));
- if(url && !isSame) {
+ var url = xhr.getResponseHeader('X-ControllerURL'),
+ // TODO Replaces trailing slashes added by History after locale (e.g. admin/?locale=en/)
+ origUrl = History.getPageUrl().replace(/\/$/, ''),
+ opts, requestHeaders = settings.headers;
+
+ if(url !== null && !isSameUrl(origUrl, url)) {
opts = {pjax: xhr.getResponseHeader('X-Pjax') ? xhr.getResponseHeader('X-Pjax') : settings.headers['X-Pjax']};
window.History.pushState(opts, '', url);
}
@@ -144,8 +166,9 @@ jQuery.noConflict();
* - {String} url
* - {String} title New window title
* - {Object} data Any additional data passed through to History.pushState()
+ * - {boolean} forceReload Forces the replacement of the current history state, even if the URL is the same, i.e. allows reloading.
*/
- loadPanel: function(url, title, data) {
+ loadPanel: function(url, title, data, forceReload) {
if(!data) data = {};
if(!title) title = "";
@@ -169,13 +192,26 @@ jQuery.noConflict();
if(window.History.enabled) {
// Active menu item is set based on X-Controller ajax header,
// which matches one class on the menu
- window.History.pushState(data, title, url);
+ if(forceReload) {
+ // Add a parameter to make sure the page gets reloaded even if the URL is the same.
+ $.extend(data, {__forceReload: Math.random()});
+ window.History.replaceState(data, title, url);
+ } else {
+ window.History.pushState(data, title, url);
+ }
} else {
window.location = $.path.makeUrlAbsolute(url, $('base').attr('href'));
}
},
/**
+ * Nice wrapper for reloading current history state.
+ */
+ reloadCurrentPanel: function() {
+ this.loadPanel(window.History.getState().url, null, null, true);
+ },
+
+ /**
* Function: submitForm
*
* Parameters:
@@ -887,11 +923,9 @@ jQuery.noConflict();
ajaxOptions: {
// Overwrite ajax loading to use CMS logic instead
beforeSend: function(xhr, settings) {
- var makeAbs = $.path.makeUrlAbsolute,
- baseUrl = $('base').attr('href'),
- isSame = (makeAbs(settings.url, baseUrl) == makeAbs(document.location.href));
-
- if(!isSame) $('.cms-container').loadPanel(settings.url);
+ if(!isSameUrl(document.location.href, settings.url)) {
+ $('.cms-container').loadPanel(settings.url);
+ }
return false;
}
},
@@ -14,8 +14,6 @@
SelectParser = (function() {
- SelectParser.name = 'SelectParser';
-
function SelectParser() {
this.options_index = 0;
this.parsed = [];
@@ -109,8 +107,6 @@ Copyright (c) 2011 by Harvest
AbstractChosen = (function() {
- AbstractChosen.name = 'AbstractChosen';
-
function AbstractChosen(form_field, options) {
this.form_field = form_field;
this.options = options != null ? options : {};
@@ -280,7 +276,7 @@ Copyright (c) 2011 by Harvest
(function() {
var $, Chosen, get_side_border_padding, root,
__hasProp = {}.hasOwnProperty,
- __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor; child.__super__ = parent.prototype; return child; };
+ __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
root = this;
@@ -305,8 +301,6 @@ Copyright (c) 2011 by Harvest
__extends(Chosen, _super);
- Chosen.name = 'Chosen';
-
function Chosen() {
return Chosen.__super__.constructor.apply(this, arguments);
}
@@ -325,7 +319,6 @@ Copyright (c) 2011 by Harvest
this.container_id = this.form_field.id.length ? this.form_field.id.replace(/(:|\.)/g, '_') : this.generate_field_id();
this.container_id += "_chzn";
this.f_width = this.form_field_jq.outerWidth();
- if (this.f_width==0) this.f_width = this.form_field_jq.css("width");
this.default_text = this.form_field_jq.data('placeholder') ? this.form_field_jq.data('placeholder') : this.default_text_default;
container_div = $("<div />", {
id: this.container_id,
@@ -348,7 +341,7 @@ Copyright (c) 2011 by Harvest
rise = this.rise_up(this.container, this.dropdown);
dd_top = rise ? -this.container.find('.chzn-drop').height() : this.container.height();
- dd_width = this.container.width - get_side_border_padding(this.dropdown);
+ dd_width = this.container.width() - get_side_border_padding(this.dropdown);
this.dropdown.css({
"width": dd_width + "px",
"top": dd_top + "px"

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -14,8 +14,6 @@
SelectParser = (function() {
- SelectParser.name = 'SelectParser';
-
function SelectParser() {
this.options_index = 0;
this.parsed = [];
@@ -109,8 +107,6 @@ Copyright (c) 2011 by Harvest
AbstractChosen = (function() {
- AbstractChosen.name = 'AbstractChosen';
-
function AbstractChosen(form_field, options) {
this.form_field = form_field;
this.options = options != null ? options : {};
@@ -280,16 +276,14 @@ Copyright (c) 2011 by Harvest
(function() {
var Chosen, get_side_border_padding, root,
__hasProp = {}.hasOwnProperty,
- __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor; child.__super__ = parent.prototype; return child; };
+ __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
root = this;
Chosen = (function(_super) {
__extends(Chosen, _super);
- Chosen.name = 'Chosen';
-
function Chosen() {
return Chosen.__super__.constructor.apply(this, arguments);
}

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -60,7 +60,7 @@ class Chosen extends AbstractChosen
dd_top = if rise then -this.container.find('.chzn-drop').height() else @container.height()
#patch applied: https://github.com/harvesthq/chosen/issues/300
- dd_width = (@container.width - get_side_border_padding(@dropdown))
+ dd_width = (@container.width() - get_side_border_padding(@dropdown))
@dropdown.css({"width": dd_width + "px", "top": dd_top + "px"})
View
@@ -144,6 +144,7 @@ static function linkToFeed($url, $title = null) {
*/
function Entries() {
$output = new ArrayList();
+
if(isset($this->entries)) {
foreach($this->entries as $entry) {
$output->push(new RSSFeed_Entry($entry, $this->titleField, $this->descriptionField, $this->authorField));
@@ -183,7 +184,10 @@ function Description() {
/**
* Output the feed to the browser
*/
- function outputToBrowser() {
+ public function outputToBrowser() {
+ $prevState = SSViewer::get_source_file_comments();
+ SSViewer::set_source_file_comments(false);
+
if(is_int($this->lastModified)) {
HTTP::register_modification_timestamp($this->lastModified);
header('Last-Modified: ' . gmdate("D, d M Y H:i:s", $this->lastModified) . ' GMT');
@@ -192,26 +196,14 @@ function outputToBrowser() {
HTTP::register_etag($this->etag);
}
- $body = $this->feedContent();
- HTTP::add_cache_headers();
- header("Content-type: text/xml");
- echo $body;
- }
-
- /**
- * Return the content of the RSS feed.
- *
- * Also temporarily disabled source file comments, and restores
- * to previous state once content has been rendered.
- *
- * @return string
- */
- function feedContent() {
- $prevState = SSViewer::get_source_file_comments();
- SSViewer::set_source_file_comments(false);
- $content = str_replace('&nbsp;', '&#160;', $this->renderWith($this->getTemplate()));
+ if(!headers_sent()) {
+ HTTP::add_cache_headers();
+ header("Content-type: text/xml");
+ }
+
SSViewer::set_source_file_comments($prevState);
- return $content;
+
+ return $this->renderWith($this->getTemplate());
}
/**
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
View
@@ -416,7 +416,6 @@ static function showError($errno, $errstr, $errfile, $errline, $errcontext, $err
}
$reporter->writeTrace(($errcontext ? $errcontext : debug_backtrace()));
$reporter->writeFooter();
- exit(1);
}
/**
View
@@ -984,6 +984,7 @@ class Installer extends InstallRequirements {
?>
<html>
<head>
+ <meta charset="utf-8" />
<title>Installing SilverStripe...</title>
<link rel="stylesheet" type="text/css" href="<?php echo FRAMEWORK_NAME; ?>/dev/install/css/install.css" />
<script src="<?php echo FRAMEWORK_NAME; ?>/thirdparty/jquery/jquery.js"></script>
@@ -1352,7 +1353,8 @@ TEXT;
method: 'get',
url: 'InstallerTest/testrewrite',
complete: function(response) {
- if(response.responseText == 'OK') {
+ var r = response.responseText.replace(/[^A-Z]?/g,"");
+ if(r === "OK") {
$('#ModRewriteResult').html("Friendly URLs set up successfully; I am now redirecting you to your SilverStripe site...")
setTimeout(function() {
window.location = "$destinationURL";
@@ -127,6 +127,10 @@ in jQuery.entwine, we're trying to reuse library code wherever possible.
The most prominent example of this is the usage of [jQuery UI](http://jqueryui.com) for
dialogs and buttons.
+The CMS includes the jQuery.entwine inspector. Press Ctrl+` to bring down the inspector.
+You can then click on any element in the CMS to see which entwine methods are bound to
+any particular element.
+
## JavaScript and CSS dependencies via Requirements and Ajax
The JavaScript logic powering the CMS is divided into many files,
@@ -222,6 +222,9 @@ This is a deliberately simple example, the strength of jQuery.entwine over simpl
properties, namespacing, as well as its inheritance based on CSS selectors. Please see the [project
documentation](http://github.com/hafriedlander/jquery.entwine/tree/master) for more complete examples.
+When working in the CMS, the CMS includes the jQuery.entwine inspector. Press Ctrl+` to bring down the inspector.
+You can then click on any element in the CMS to see which entwine methods are bound to any particular element.
+
## Architecture and Best Practices
### Keep things simple
Oops, something went wrong.

0 comments on commit 4cc82e9

Please sign in to comment.